dir
Listing and making directories
The functions of nanyx.fs/dir list and make directories, each requiring FileSystem. Import the
module under its own name, import nanyx.fs/dir as dir, to call them as dir.list and dir.create. A listing
gives the path of each thing in the directory, sorted, so it can be read straight away:
match dir.list(path.of("notes"))
| #some(paths) ->
for note in paths do
println(note)
| #error(#notFound) -> println("No notes yet")
| #error(e) -> eprintln("Couldn't list the notes: {e}")
Reference
Listing and making directories.
Each function requires FileSystem, and gives what went wrong as an
FsError. Import the module as import nanyx.fs/dir as dir to call dir.list and
dir.create by those names.
list
def list: [Async, FileSystem] Path -> #some(list(Path)) | #error(FsError)
The paths of what the directory at at holds, its files and directories, each at joined with
its name, sorted by name.
create
def create: [Async, FileSystem] Path -> #ok | #error(FsError)
Makes the directory at. Its parent must be there already, and #error(#alreadyExists) says
something is at at already.