Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
api:filesystem [2014/08/15 13:56]
sangar
api:filesystem [2015/08/01 07:30]
shuudoushi
Line 10: Line 10:
   Returns the canonical form of the specified path, i.e. a path containing no "​indirections"​ such as `.` or `..`. For example, the paths `/​tmp/​../​bin/​ls.lua` and `/​bin/​./​ls.lua` are equivalent, and their canonical form is `/​bin/​ls.lua`.  ​   Returns the canonical form of the specified path, i.e. a path containing no "​indirections"​ such as `.` or `..`. For example, the paths `/​tmp/​../​bin/​ls.lua` and `/​bin/​./​ls.lua` are equivalent, and their canonical form is `/​bin/​ls.lua`.  ​
   Note that this function truncates relative paths to their topmost "​known"​ directory. For example, `../​bin/​ls.lua` becomes `bin/​ls.lua`. It stays a relative path, however - mind the lack of a leading slash.   Note that this function truncates relative paths to their topmost "​known"​ directory. For example, `../​bin/​ls.lua` becomes `bin/​ls.lua`. It stays a relative path, however - mind the lack of a leading slash.
 +- `filesystem.segments(path:​ string): table`  ​
 +  Returns a table containing one entry for each //​canonical//​ segment of the given path.
 +  Examples:  ​
 +  * `filesystem.segments("​foo/​bar"​)` -> `{"​foo","​bar"​}`
 +  * `filesystem.segments("​foo/​bar/​../​baz"​)` -> `{"​foo","​baz"​}`
 +
 - `filesystem.concat(pathA:​ string, pathB: string[, ...]): string`  ​ - `filesystem.concat(pathA:​ string, pathB: string[, ...]): string`  ​
   Concatenates two or more paths. Note that all paths other than the first are treated as relative paths, even if they begin with a slash. The canonical form of the resulting concatenated path is returned, so `fs.concat("​a",​ "​.."​)` results in an empty string.   Concatenates two or more paths. Note that all paths other than the first are treated as relative paths, even if they begin with a slash. The canonical form of the resulting concatenated path is returned, so `fs.concat("​a",​ "​.."​)` results in an empty string.
Line 38: Line 44:
   Gets whether the path points to a directory. Returns false if not, either because the path points to a file, or `file.exists(path)` is false.   Gets whether the path points to a directory. Returns false if not, either because the path points to a file, or `file.exists(path)` is false.
 - `filesystem.lastModified(path:​ string): number`  ​ - `filesystem.lastModified(path:​ string): number`  ​
-  Returns the *real world* ​unicode ​timestamp of the last time the file at the specified path was modified. For directories this is usually the time of their creation.+  Returns the *real world* ​unix timestamp of the last time the file at the specified path was modified. For directories this is usually the time of their creation.
 - `filesystem.list(path:​ string): function -> string or nil, string`  ​ - `filesystem.list(path:​ string): function -> string or nil, string`  ​
   Returns an iterator over all elements in the directory at the specified path. Returns `nil` and an error messages if the path is invalid or some other error occurred.  ​   Returns an iterator over all elements in the directory at the specified path. Returns `nil` and an error messages if the path is invalid or some other error occurred.  ​