z_filelib (zotonic_stdlib v1.31.1)
View SourceExtra file functions to complement the standard library. Rename files between different filesystems, and ensure directories of a path exist. Also escape routines to safely handle filenames as command line arguments.
Summary
Functions
Ensure the directory of a file is present. This will still work if a soft-link in the path refers to a missing directory.
Simple escape function for command line arguments. Escapes special characters in the filename using backslashes. The path is not quoted, use os_filename/1 for that.
Simple escape function for filenames as commandline arguments. The result includes quotes.
Rename a file. Copy the file on a cross-fs error.
Functions
-spec ensure_dir(file:filename_all()) -> ok | {error, term()}.
Ensure the directory of a file is present. This will still work if a soft-link in the path refers to a missing directory.
Simple escape function for command line arguments. Escapes special characters in the filename using backslashes. The path is not quoted, use os_filename/1 for that.
Simple escape function for filenames as commandline arguments. The result includes quotes.
-spec rename(From, To) -> ok | {error, term()} when From :: file:filename_all(), To :: file:filename_all().
Rename a file. Copy the file on a cross-fs error.