Module file_util

Source
Expand description

Various utility functions, primarily wrapping the standard library’s IO and filesystem functions

Structs§

Guard
Lock
Blocks until the lock can be acquired.

Enums§

LockOptions

Constants§

LOCK_FILE_NAME

Functions§

canonicalize
copy
Copies the file or directory at source into the target path. If the source is a file and the target is not a directory, the source file is copied to the target path. If the source is a file and the target is a directory, the source file is copied into the target directory. If the source is a directory and the target is not a file, the source directory and all files in it are copied recursively into the target directory. For example, with source=dir1 and target=dir2, dir1/file would be copied to dir2/dir1/file. If the source is a directory and the target is a file, an error is returned.
create_dir
create_dir_all
create_file
Note: creates all intermediary directories if needed.
named_temp_file
named_temp_file_in
open_file
read_dir
read_file
read_file_to_string
read_file_to_string_lossy
read_reader
read_to_file
Reads all of the data from source and writes it into a new file at target.
remove_all
Removes whatever is at the path, whether it is a directory or file. The _all suffix hopefully makes the function sound at least slightly dangerous.
remove_dir_all
remove_dir_empty
remove_file
remove_file_locked
rename
temp_file
write_to_file
write_to_writer