March Docs

Dir

Dir module: directory I/O. All operations return Result(value, FileError) except exists which returns Bool. rm_rf does not follow symlinks; symlink entries are removed, targets left intact. rm_rf refuses to operate on "/" or "" (returns Err).

Functions

fnexistsexists(path)#

True if the path exists and is a directory (not a regular file). Use File.exists/1 for a generic any-kind-of-entry check.

Examples

    march> Dir.exists("/")
    true
    march> Dir.exists("/this/path/does/not/exist")
    false
fnlistlist(path)#

List the entries of a directory as bare names (no path prefix). Returns Ok(names) on success or Err(file_error) (e.g. NotFound, Permission). Names are returned in directory order — typically not sorted.

Examples

    march> Dir.list("/this/path/does/not/exist")
    Err(NotFound("/this/path/does/not/exist"))
fnlist_fulllist_full(path)#

Like list/1 but each returned entry is prefixed with path/. Useful when the caller wants ready-to-open paths instead of bare names.

Examples

    march> Dir.list_full("/this/path/does/not/exist")
    Err(NotFound("/this/path/does/not/exist"))
fnmkdirmkdir(path)#

Create a single directory. Fails if the parent does not exist or if path already exists; use mkdir_p/1 for "mkdir -p" semantics.

fnmkdir_pmkdir_p(path)#

Create a directory and any missing intermediate parents (POSIX mkdir -p). Succeeds silently if the target already exists.

fnrm_rfrm_rf(path)#

Recursively remove a directory tree. Symlinks inside the tree are removed but their targets are left intact. Refuses to operate on "/" or "" and returns Err instead — destructive enough that an accidental call deserves to fail loudly.

fnrmdirrmdir(path)#

Remove an empty directory. Use rm_rf/1 to recursively remove a populated directory tree. Returns Err(NotEmpty(path)) when called on a non-empty directory.