diff options
| author | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-07 07:39:47 -0400 |
|---|---|---|
| committer | Marshall Lochbaum <mwlochbaum@gmail.com> | 2021-04-07 07:39:47 -0400 |
| commit | 83839ce9eb4b0a2d38e6b950a8b63552e089d371 (patch) | |
| tree | 48b6a04a56e3f3fde032240f7ab3155590e2a9ed | |
| parent | d774e7b23ea6b03e5999bc6ebdf3245efac8dd83 (diff) | |
Add CreateDir and List for directory manipulation
| -rw-r--r-- | docs/spec/system.html | 13 | ||||
| -rw-r--r-- | spec/system.md | 8 |
2 files changed, 17 insertions, 4 deletions
diff --git a/docs/spec/system.html b/docs/spec/system.html index d8a1e26d..5181867e 100644 --- a/docs/spec/system.html +++ b/docs/spec/system.html @@ -155,7 +155,7 @@ </table> <p>Times are Unix timestamps, that is, seconds since the Unix epoch, as used by <a href="#time">time</a> system values.</p> <h3 id="file-access">File access</h3> -<p>File access functions read or write files, either by manipulating files as a whole or interacting with the contents. Whole-file functions cannot overwrite target files: that is, <code><span class='Function'>Rename</span></code> and <code><span class='Function'>Copy</span></code> must give an error if a file exists at <code><span class='Value'>𝕨</span></code>, while <code><span class='Function'>Chars</span></code>, <code><span class='Function'>Lines</span></code>, and <code><span class='Function'>Bytes</span></code> can overwrite the contents of an existing file <code><span class='Value'>𝕨</span></code>. However, these three functions must give an error if <code><span class='Value'>𝕨</span></code> exists and is a directory.</p> +<p>File access functions read or write files, either by manipulating files as a whole or interacting with the contents. Whole-file functions cannot overwrite target files: that is, <code><span class='Function'>Rename</span></code> and <code><span class='Function'>Copy</span></code> must give an error if a file exists at <code><span class='Value'>𝕨</span></code>, and <code><span class='Function'>CreateDir</span></code> if a file exists at <code><span class='Value'>𝕩</span></code>, while <code><span class='Function'>Chars</span></code>, <code><span class='Function'>Lines</span></code>, and <code><span class='Function'>Bytes</span></code> can overwrite the contents of an existing file <code><span class='Value'>𝕨</span></code>. However, these three functions must give an error if <code><span class='Value'>𝕨</span></code> exists and is a directory.</p> <table> <thead> <tr> @@ -177,6 +177,10 @@ <td>Copy file <code><span class='Value'>𝕩</span></code> to path <code><span class='Value'>𝕨</span></code></td> </tr> <tr> +<td><code><span class='Function'>CreateDir</span></code></td> +<td>Create a directory at path <code><span class='Value'>𝕩</span></code></td> +</tr> +<tr> <td><code><span class='Function'>Remove</span></code></td> <td>Delete file <code><span class='Value'>𝕩</span></code></td> </tr> @@ -185,6 +189,10 @@ <td>Recursively delete directory <code><span class='Value'>𝕩</span></code> and all contents</td> </tr> <tr> +<td><code><span class='Function'>List</span></code></td> +<td>Return names of all files in directory <code><span class='Value'>𝕩</span></code></td> +</tr> +<tr> <td><code><span class='Function'>Chars</span></code></td> <td>Read from or write to entire file, as characters</td> </tr> @@ -198,7 +206,8 @@ </tr> </tbody> </table> -<p><code><span class='Function'>Rename</span></code> and <code><span class='Function'>Copy</span></code> return the path of the new file. <code><span class='Function'>Remove</span></code> and <code><span class='Function'>RemoveDir</span></code> return <code><span class='Number'>1</span></code> to indicate successful removal (and error otherwise).</p> +<p><code><span class='Function'>Rename</span></code>, <code><span class='Function'>Copy</span></code>, and <code><span class='Function'>CreateDir</span></code> return the path of the new file. <code><span class='Function'>Remove</span></code> and <code><span class='Function'>RemoveDir</span></code> return <code><span class='Number'>1</span></code> to indicate successful removal (and error otherwise).</p> +<p><code><span class='Function'>List</span></code> returns filenames only, without extensions. It lists all files and directories including hidden ones, but not the current and parent directory names <code><span class='Value'>.</span></code> and <code><span class='Value'>..</span></code>.</p> <p>Functions <code><span class='Function'>Chars</span></code>, <code><span class='Function'>Lines</span></code>, and <code><span class='Function'>Bytes</span></code> are all ambivalent. If only <code><span class='Value'>𝕩</span></code> is given, then it is a filename, and the result is the contents of the file in the appropriate format. If there are two arguments, then <code><span class='Value'>𝕨</span></code> is the filename and <code><span class='Value'>𝕩</span></code> is the desired contents. These are written to the file, overwriting its contents, and the absolute filename <code><span class='Value'>𝕨</span></code> is returned. The three formats are:</p> <ul> <li>Chars: BQN characters, or UTF-32. The file is assumed to be UTF-8 encoded.</li> diff --git a/spec/system.md b/spec/system.md index 67989d31..06722d76 100644 --- a/spec/system.md +++ b/spec/system.md @@ -80,20 +80,24 @@ Times are Unix timestamps, that is, seconds since the Unix epoch, as used by [ti ### File access -File access functions read or write files, either by manipulating files as a whole or interacting with the contents. Whole-file functions cannot overwrite target files: that is, `Rename` and `Copy` must give an error if a file exists at `𝕨`, while `Chars`, `Lines`, and `Bytes` can overwrite the contents of an existing file `𝕨`. However, these three functions must give an error if `𝕨` exists and is a directory. +File access functions read or write files, either by manipulating files as a whole or interacting with the contents. Whole-file functions cannot overwrite target files: that is, `Rename` and `Copy` must give an error if a file exists at `𝕨`, and `CreateDir` if a file exists at `𝕩`, while `Chars`, `Lines`, and `Bytes` can overwrite the contents of an existing file `𝕨`. However, these three functions must give an error if `𝕨` exists and is a directory. | Name | Summary |-------------|-------------------------- | `Open` | Return an open file object based on `𝕩` | `Rename` | Rename file `𝕩` with path `𝕨` | `Copy` | Copy file `𝕩` to path `𝕨` +| `CreateDir` | Create a directory at path `𝕩` | `Remove` | Delete file `𝕩` | `RemoveDir` | Recursively delete directory `𝕩` and all contents +| `List` | Return names of all files in directory `𝕩` | `Chars` | Read from or write to entire file, as characters | `Lines` | Read from or write to entire file, as lines | `Bytes` | Read from or write to entire file, as bytes -`Rename` and `Copy` return the path of the new file. `Remove` and `RemoveDir` return `1` to indicate successful removal (and error otherwise). +`Rename`, `Copy`, and `CreateDir` return the path of the new file. `Remove` and `RemoveDir` return `1` to indicate successful removal (and error otherwise). + +`List` returns filenames only, without extensions. It lists all files and directories including hidden ones, but not the current and parent directory names `.` and `..`. Functions `Chars`, `Lines`, and `Bytes` are all ambivalent. If only `𝕩` is given, then it is a filename, and the result is the contents of the file in the appropriate format. If there are two arguments, then `𝕨` is the filename and `𝕩` is the desired contents. These are written to the file, overwriting its contents, and the absolute filename `𝕨` is returned. The three formats are: |
