This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
api:filesystem [2015/01/14 23:40] 127.0.0.1 external edit |
api:filesystem [2015/02/01 01:42] solra_bizna [Filesystem API] Eek! That isn't actually possible in current version! |
||
---|---|---|---|
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. |