hare

The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit a5e971a6d7227f20075302bdd60102f804d65b70
parent f977d0a8af5f3cd277f7280e78cc57a9f2af5856
Author: Drew DeVault <sir@cmpwn.com>
Date:   Tue,  9 Mar 2021 15:43:30 -0500

os: add rmdir, rmdirall shortcuts

Diffstat:
Mos/fs.ha | 11+++++++++++
1 file changed, 11 insertions(+), 0 deletions(-)

diff --git a/os/fs.ha b/os/fs.ha @@ -7,6 +7,9 @@ export let root: *fs::fs = null: *fs::fs; // Provides an implementation of [fs::fs] for the current working directory. export let cwd: *fs::fs = null: *fs::fs; +// Removes a file. +export fn remove(path: path::path) (void | fs::error) = fs::remove(cwd, path); + // Creates an [fs::iterator] for a given directory to read its contents. export fn iterdir(path: path::path) (*fs::iterator | fs::error) = fs::iter(cwd, path); @@ -28,6 +31,14 @@ export fn mkdir(path: path::path) (void | fs::error) = fs::mkdir(cwd, path); // Creates a directory, and all non-extant directories in its path. export fn mkdirs(path: path::path) (void | fs::error) = fs::mkdirs(cwd, path); +// Removes a directory. The target directory must be empty; see [rmdirall] to +// remove its contents as well. +export fn rmdir(path: path::path) (void | fs::error) = fs::rmdir(cwd, path); + +// Removes a directory, and anything in it. +export fn rmdirall(path: path::path) (void | fs::error) = + fs::rmdirall(cwd, path); + // Creates a directory and returns a subdir for it. Some filesystems support // doing this operation atomically, but if not, a fallback is used. export fn mksubdir(path: path::path) (*fs::fs | fs::error) =