crow/io/file.crow
(source)
path-already-exists
record
exception
variant-member
exception
variant-memberpath
string
show
string
(a
path-already-exists
)
path-not-found
record
exception
variant-member
exception
variant-memberpath
string
show
string
(a
path-not-found
)
file-system-error
record
exception
variant-member
exception
variant-membershow
string
(a
file-system-error
)
path-exists
bool
(path
string
) summon
true
iff anything (like a file or directory) exists at the path.
is-directory
bool
(path
string
) summon
true
if path
is the path of a directory.false
if the path is a file.true
if the path is a symlink to a directory.false
if nothing exists at the path.
path-kind
enum
file
directory
other
get-path-kind
path-kind
(path
string
) summon
paths-in-dir
string
array
(path
string
) summon
Returns all children of the directory path
, as full paths.
Use names-in-dir
if you just want their names.
names-in-dir
string
array
(path
string
) summon
Returns the basename of all children of the directory.
Does not include ".." or ".".
Use paths-in-dir
if you want full paths.
read-link
string
(path
string
) summon
Gets the path a symbolic link refers to.
make-symlink-to
void
(link
string
, target
string
) summon
Create a symbolic link at link
with the target target
.
current-executable-path
string
() summon
Gets the path of the current executable.
If this program was built to executable, this will return its path.
Otherwise, this will be the path where crow
is installed.
not-a-text-file
record
exception
variant-member
exception
variant-memberpath
string
show
string
(a
not-a-text-file
)
read-file
string
(path
string
) summon
Reads the full contents of the file.
read-file-or-empty
string
(path
string
) summon
Like 'read-file', but returns an empty string instead of throwing 'path-not-found'.
write-file
void
(path
string
, content
string
) summon
Writes the full contents of the file as a string.
If the file already exists, overwrites it.
read-file
nat8
array
(path
string
) summon
current-directory
string
() summon
Gets the current directory (of the user that ran the program).
each-child-recursive
void
(path
string
, f
mut
void
(string
)) summon
If path
is a directory, calls each-child-recursive
on every child of the directory.
Else, calls f[path]
.
each-child-recursive
void
(path
string
, filter
mut
bool
(string
), f
mut
void
(string
)) summon
Like each-child-recursive
, but calls filter
on names of directory children
and skips them if filter
returns false.
file-permissions
record
user
permissions
group
permissions
public
permissions
POSIX file permissions.
permissions
record
Permissions for one of user, group, public.
no-permissions
permissions
()
all-permissions
permissions
()
user-only
file-permissions
(user-permissions
permissions
)
make-directory
void
(path
string
) summon
Creates a new empty directory at path
.
make-directory
void
(path
string
, permissions
file-permissions
) summon
ensure-directory
void
(path
string
) summon
Like 'make-directory', but OK if it already exists.
remove-file
void
(path
string
) summon
Deletes the file at path
.
remove-directory
void
(path
string
) summon
Deletes the directory at path
.
It should be empty.
null-path
string
() unsafe
"/dev/null" or "NUL" on windows