Added docs.
@@ -185,6 +185,18 @@ "kind": "symbol",
"name": "abs", "signature": "num1 ==> num2" }, + "absolute-path": { + "description": "Returns the absolute path to 'sym.", + "kind": "symbol", + "name": "absolute-path", + "signature": "'sym ==> str" + }, + "absolute-path?": { + "description": "Returns true if 'sym is an absolute path.", + "kind": "symbol", + "name": "absolute-path?", + "signature": "'sym ==> bool" + }, "accept": { "description": "Makes dict:socket2 (server) accept a connection from dict:socket1 (client). Returns the client socket dict:socket1 from which it will be possible to receive data from.", "kind": "symbol",@@ -196,6 +208,12 @@ "description": "Calculates the arc cosine of num1 (in radians).",
"kind": "symbol", "name": "acos", "signature": "num1 ==> num2" + }, + "admin?": { + "description": "Returns true if the program is being run with administrative privileges.", + "kind": "symbol", + "name": "admin?", + "signature": " ==> bool" }, "aes": { "description": "Encrypts or decrypts 'sym1 using the Advanced Encryption Standard (AES) in CTR mode, using 'sym2 as password.",@@ -730,6 +748,18 @@ "description": "Exits the program or shell with int as return code.",
"kind": "symbol", "name": "exit", "signature": "int ==> " + }, + "expand-filename": { + "description": "Returns the absolute path to the file name 'sym.", + "kind": "symbol", + "name": "expand-filename", + "signature": "'sym ==> str" + }, + "expand-symlink": { + "description": "Returns the absolute path to the symlink 'sym (an error is raised if 'sym is not a symlink).", + "kind": "symbol", + "name": "expand-symlink", + "signature": "'sym ==> str" }, "expect": { "description": "If the -d (--dev) flag is specified when running the program, validates the first _n_ elements of the stack against the type descriptions specified in quot1 (_n_ is quot1's length) and if all the elements are valid returns them wrapped in quot2 (in reverse order). If the -d (--dev) flag is not specified when running the program, no validation is performed and all elements are just returned in a quotation in reverse order. \n\n \n Tips\n \n * You can specify a typed dictionary by prepending the type name with dict:. Example: dict:socket\n * You can specify two or more matching types by separating combined together in a logical type expression, e.g.: string|quot\n\n \n Example\n \n Assuming that the following elements are on the stack (from top to bottom): \n \n 1 \"test\" 3.4\n \n the following program evaluates to true:\n \n (int string num) expect (3.4 \"test\" 1) ==",@@ -1043,6 +1073,12 @@ "kind": "symbol",
"name": "join", "signature": "quot 'sym ==> str" }, + "join-path": { + "description": "Joins the strings contained in quot with /.", + "kind": "symbol", + "name": "join-path", + "signature": "quot ==> str" + }, "keep": { "description": "Applies each quotation contained in the first element to each subsequent corresponding element.\n \n Example\n \n The following program leaves 5 3 on the stack:\n \n 2 3 '+ keep", "kind": "symbol",@@ -1228,6 +1264,12 @@ "description": "Removes the second element from the stack.",
"kind": "symbol", "name": "nip", "signature": "a1 a2 ==> a2" + }, + "normalized-path": { + "description": "Returns the normalized path to 'sym.", + "kind": "symbol", + "name": "normalized-path", + "signature": "'sym ==> str" }, "not": { "description": "Negates bool1.",@@ -1517,6 +1559,12 @@ "kind": "symbol",
"name": "reject", "signature": "quot1 quot2 ==> quot3" }, + "relative-path": { + "description": "Returns the path of 'sym1 relative to 'sym2.", + "kind": "symbol", + "name": "relative-path", + "signature": "'sym1 'sym2 ==> str" + }, "remove": { "description": "Returns the _n^th_ element of quot1 (zero-based), and returns the modified copy of the quotation quot2.", "kind": "symbol",@@ -2069,6 +2117,12 @@ "kind": "symbol",
"name": "union", "signature": "quot1 quot2 ==> quot3" }, + "unix-path": { + "description": "Converts all backslashes in 'sym to slashes.", + "kind": "symbol", + "name": "unix-path", + "signature": "'sym ==> str" + }, "unless": { "description": "If 1 evaluates to false then evaluates 2.", "kind": "symbol",@@ -2134,6 +2188,12 @@ "description": "Executes quot2 while quot1 evaluates to true.\n \n \n Example\n \n The following program prints all natural numbers from 0 to 10:\n \n 0 :count \n (count 10 <=) \n (count puts succ @count) while",
"kind": "symbol", "name": "while", "signature": "quot1 quot2 ==> a*" + }, + "windows-path": { + "description": "Converts all slashes in 'sym to backslashes.", + "kind": "symbol", + "name": "windows-path", + "signature": "'sym ==> str" }, "with": { "description": "Pushes each item of quot1 on the stack using the scope of quot2 as scope.",
@@ -121,15 +121,15 @@ for p in vals[0].qVal:
if not p.isStringLike: raiseInvalid("A quotation of strings is required") fragments.add(p.getString) - i.push fragments.joinPath.newVal + i.push fragments.joinPath.unix.newVal def.symbol("expand-filename") do (i: In): let vals = i.expect("'sym") - i.push vals[0].getString.expandFilename.newVal + i.push vals[0].getString.expandFilename.unix.newVal def.symbol("expand-symlink") do (i: In): let vals = i.expect("'sym") - i.push vals[0].getString.expandSymlink.newVal + i.push vals[0].getString.expandSymlink.unix.newVal def.symbol("normalized-path") do (i: In): let vals = i.expect("'sym")@@ -141,11 +141,11 @@ def.symbol("relative-path") do (i: In):
let vals = i.expect("'sym", "'sym") let p = vals[1].getString let base = vals[0].getString - i.push relativePath(p, base).newVal + i.push relativePath(p, base).unix.newVal def.symbol("absolute-path") do (i: In): let vals = i.expect("'sym") - i.push vals[0].getString.absolutePath.newVal + i.push vals[0].getString.absolutePath.unix.newVal def.symbol("windows-path") do (i: In): let vals = i.expect("'sym")
@@ -26,4 +26,5 @@ * Added **admin?** symbol to the **sys** module.
### Fixes and Improvements +* Fixed Nim 1.6.0 compilation warnings. * string values are now properly escaped when printed.
@@ -4,6 +4,12 @@ title: "fs Module"
----- {@ _defs_.md || 0 @} +{#op||absolute-path||{{sl}}||{{s}}|| +Returns the absolute path to {{sl}}. #} + +{#op||absolute-path?||{{sl}}||{{b}}|| +Returns {{t}} if {{sl}} is an absolute path. #} + {#op||atime||{{sl}}||{{flt}}|| Returns a timestamp corresponding to the time that file/directory {{sl}} was last accessed.#}@@ -18,6 +24,12 @@ Returns {{t}} if the specified path {{sl}} exists and is a directory. #}
{#op||exists?||{{sl}}||{{b}}|| Returns {{t}} if the specified file or directory {{sl}} exists. #} + +{#op||expand-filename||{{sl}}||{{s}}|| +Returns the absolute path to the file name {{sl}}. #} + +{#op||expand-symlink||{{sl}}||{{s}}|| +Returns the absolute path to the symlink {{sl}} (an error is raised if {{sl}} is not a symlink). #} {#op||file?||{{sl}}||{{b}}|| Returns {{t}} if the specified path {{sl}} exists and is a file. #}@@ -61,8 +73,23 @@
{#op||hidden?||{{sl}}||{{b}}|| Returns {{t}} if file/directory {{sl}} is hidden, {{f}} otherwise.#} +{#op||join-path||{{q}}||{{s}}|| +Joins the strings contained in {{q}} with `/`.#} + +{#op||normalized-path||{{sl}}||{{s}}|| +Returns the normalized path to {{sl}}. #} + {#op||mtime||{{sl}}||{{flt}}|| Returns a timestamp corresponding to the time that file/directory {{sl}} was last modified.#} + +{#op||relative-path||{{sl1}} {{sl2}}||{{s}}|| +Returns the path of {{sl1}} relative to {{sl2}}. #} {#op||symlink?||{{sl}}||{{b}}|| Returns {{t}} if the specified path {{sl}} exists and is a symbolic link. #} + +{#op||unix-path||{{sl}}||{{s}}|| +Converts all backslashes in {{sl}} to slashes. #} + +{#op||windows-path||{{sl}}||{{s}}|| +Converts all slashes in {{sl}} to backslashes. #}
@@ -22,6 +22,9 @@
{#op||..||{{none}}||{{s}}|| Returns the full path to the parent directory. #} +{#op||admin?||{{none}}||{{b}}|| +Returns {{t}} if the program is being run with administrative privileges. #} + {#op||chmod||{{sl}} {{i}}||{{none}}|| > Sets the permissions of file or directory {{sl}} to {{i}}. {{i}} is a three-digit representation of user, group and other permissions. See the [Unix Permissions Calculator](http://permissions-calculator.org/) for examples and conversions. >