View Source z_filelib (zotonic_stdlib v1.23.1)

Extra file functions.

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

Simple escape function for filenames as commandline arguments. foo/"bar.jpg -> "foo/\"bar.jpg"; on windows "foo\\\"bar.jpg" (both including quotes!)

Functions

ensure_dir(Filename)

-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.

os_escape(A)

-spec os_escape(string() | binary() | undefined) -> string().

Simple escape function for command line arguments

os_filename(A)

-spec os_filename(string() | binary()) -> string().

Simple escape function for filenames as commandline arguments. foo/"bar.jpg -> "foo/\"bar.jpg"; on windows "foo\\\"bar.jpg" (both including quotes!)