fio
Values
pub fn append(
path: String,
content: String,
) -> Result(Nil, error.FioError)
Append UTF-8 text to a file (creates if missing).
pub fn append_bits(
path: String,
content: BitArray,
) -> Result(Nil, error.FioError)
Append raw bytes (BitArray) to a file.
pub fn checksum(
path: String,
algorithm: types.HashAlgorithm,
) -> Result(String, error.FioError)
Compute a file checksum using the specified algorithm. Returns a hex-encoded string.
pub fn copy(
src: String,
dest: String,
) -> Result(Nil, error.FioError)
Copy a file from source to destination.
pub fn copy_directory(
src: String,
dest: String,
) -> Result(Nil, error.FioError)
Recursively copy a directory and its contents.
pub fn create_directory(
path: String,
) -> Result(Nil, error.FioError)
Create a directory. Parent directory must exist.
pub fn create_directory_all(
path: String,
) -> Result(Nil, error.FioError)
Create a directory and all parent directories.
pub fn create_hard_link(
target target: String,
link link: String,
) -> Result(Nil, error.FioError)
Create a hard link to an existing file.
pub fn create_symlink(
target target: String,
link link: String,
) -> Result(Nil, error.FioError)
Create a symbolic link.
pub fn current_directory() -> Result(String, error.FioError)
Get the current working directory.
pub fn delete(path: String) -> Result(Nil, error.FioError)
Delete a file (not a directory).
pub fn delete_all(path: String) -> Result(Nil, error.FioError)
Delete a path recursively; idempotent (succeeds if missing).
pub fn delete_directory(
path: String,
) -> Result(Nil, error.FioError)
Delete an empty directory.
pub fn directory_name(path_str: String) -> String
Get the directory portion of a path.
pub fn exists(path: String) -> Bool
Check if a path exists (file, directory, or symlink).
pub fn expand(path_str: String) -> Result(String, Nil)
Expand/normalize a path, resolving . and .. segments.
Returns Error(Nil) if .. would go above the root.
pub fn extension(path_str: String) -> Result(String, Nil)
Get the file extension (without dot).
pub fn file_info(
path: String,
) -> Result(types.FileInfo, error.FioError)
Get file metadata (follows symlinks).
pub fn is_directory(path: String) -> Result(Bool, error.FioError)
Check if a path is a directory (follows symlinks).
pub fn is_file(path: String) -> Result(Bool, error.FioError)
Check if a path is a regular file (follows symlinks).
pub fn is_symlink(path: String) -> Result(Bool, error.FioError)
Check if a path is a symbolic link (does not follow symlinks).
pub fn link_info(
path: String,
) -> Result(types.FileInfo, error.FioError)
Get file metadata without following symlinks.
pub fn list(path: String) -> Result(List(String), error.FioError)
List the contents of a directory (names only).
pub fn list_recursive(
path: String,
) -> Result(List(String), error.FioError)
Recursively list files and directories (paths relative to path).
pub fn read(path: String) -> Result(String, error.FioError)
Read a UTF-8 text file. Returns NotUtf8(path) on invalid UTF-8.
pub fn read_bits(
path: String,
) -> Result(BitArray, error.FioError)
Read a file as raw bytes (BitArray).
pub fn read_link(path: String) -> Result(String, error.FioError)
Read the target path of a symbolic link.
pub fn rename(
src: String,
dest: String,
) -> Result(Nil, error.FioError)
Rename or move a file or directory.
pub fn safe_relative(path_str: String) -> Result(String, Nil)
Validate that a path is a safe relative path (does not escape root).
On Windows it also normalizes backslashes into /.
pub fn set_permissions(
path: String,
permissions: types.FilePermissions,
) -> Result(Nil, error.FioError)
Set file permissions using the FilePermissions type.
pub fn set_permissions_octal(
path: String,
mode: Int,
) -> Result(Nil, error.FioError)
Set file permissions with an octal integer.
pub fn strip_extension(path_str: String) -> String
Remove the extension from a path.
pub fn touch(path: String) -> Result(Nil, error.FioError)
Touch a file: create or update modification time.
pub fn verify_checksum(
path: String,
expected: String,
algorithm: types.HashAlgorithm,
) -> Result(Bool, error.FioError)
Verify that a file’s checksum matches the expected hex-encoded hash.
pub fn with_extension(path_str: String, ext: String) -> String
Change the extension of a path.
pub fn with_temp_directory(
callback: fn(String) -> Result(a, error.FioError),
) -> Result(a, error.FioError)
Run a callback with a path to a temporary directory that is automatically deleted (recursively) when the callback returns.
pub fn with_temp_file(
callback: fn(String) -> Result(a, error.FioError),
) -> Result(a, error.FioError)
Run a callback with a path to a temporary file that is automatically deleted when the callback returns (even if it returns an Error).
pub fn write(
path: String,
content: String,
) -> Result(Nil, error.FioError)
Write UTF-8 text to a file (creates/overwrites).
pub fn write_atomic(
path: String,
content: String,
) -> Result(Nil, error.FioError)
Write UTF-8 text atomically: writes to a sibling temp file, then renames
it into place with a single rename(2) syscall.
Readers never observe partial content. Returns AtomicFailed on error.
pub fn write_bits(
path: String,
content: BitArray,
) -> Result(Nil, error.FioError)
Write raw bytes (BitArray) to a file (creates/overwrites).
pub fn write_bits_atomic(
path: String,
content: BitArray,
) -> Result(Nil, error.FioError)
Write raw bytes (BitArray) atomically.
Same atomic guarantee as write_atomic.