1
edit
m (Fixes pointed out by tlrobinson.) |
(→Tier 1: Added some drive-path specific text. Removed ROOT.) |
||
| Line 9: | Line 9: | ||
* SEPARATOR "/" or system specific analog, like ":" or "\". | * SEPARATOR "/" or system specific analog, like ":" or "\". | ||
The File System API would provide the following methods: | The File System API would provide the following methods: | ||
| Line 18: | Line 14: | ||
* join(...paths:Strings...): takes a variadic list of path Strings, joins them on the directory separator, and normalizes the result. | * join(...paths:Strings...): takes a variadic list of path Strings, joins them on the directory separator, and normalizes the result. | ||
* split(path:String): returns a string split on the file system's directory separator. | * split(path:String): returns a string split on the file system's directory separator. The split() method will return an empty string as the first element for absolute paths that do not contain drives. For file systems with drives (such as windows), the first element will be the drive with colon if the path contained a drive specification. The intent is so that join with the SEPARATOR will correctly join the elements to reconstitute the path. | ||
* resolve(...paths:Strings...): marches through a list of variadic absolute or relative path Strings, resolving the next path relative to the previous and returning the ultimate destination path. This is analogous to navigating to the fully qualified URL of a relative URL on a given page. Unlike "join", which presumes that the base path is always a directory, "resolve" considers a directory separator at the end of a path an indication that the path must be resolved off of the directory rather than the leaf "file". For example, resolve("a", "b") returns "b", but resolve("a/", "b") returns "a/b" on a system with "/" as its directory separator. Resolving a fully qualified path relative to any base path returns the fully qualified path, like resolve("a", "/") == "/". Resolve is purely a string manipulation routine and does not use information about the underlying file system. | * resolve(...paths:Strings...): marches through a list of variadic absolute or relative path Strings, resolving the next path relative to the previous and returning the ultimate destination path. This is analogous to navigating to the fully qualified URL of a relative URL on a given page. Unlike "join", which presumes that the base path is always a directory, "resolve" considers a directory separator at the end of a path an indication that the path must be resolved off of the directory rather than the leaf "file". For example, resolve("a", "b") returns "b", but resolve("a/", "b") returns "a/b" on a system with "/" as its directory separator. Resolving a fully qualified path relative to any base path returns the fully qualified path, like resolve("a", "/") == "/". Resolve is purely a string manipulation routine and does not use information about the underlying file system. | ||
| Line 58: | Line 54: | ||
* write(path, content, [mode, [options]]): opens, writes, flushes, and closes a file with the given content. | * write(path, content, [mode, [options]]): opens, writes, flushes, and closes a file with the given content. | ||
= Tier 2 = | = Tier 2 = | ||
edit