This module groups some extensions to library system that have been found convenient, but which are still in development, their interface has not been fixed, etc.
Usage:warn_on_nosuccess(G)
Call G (cutting solutions, i.e., as once/1) and show warning messages if something went wrong (failure and exceptions).
Usage:ignore_nosuccess(G)
Call G and ignore if something went wrong (failure and exceptions).
Usage:del_dir_if_empty(D)
Delete D if it is an empty directory.
Usage:empty_dir(D)
D is an empty directory
Usage:move_files(Files,Dir)
Move Files to directory Dir (note that to move only one file to a directory, rename_file/2 can be used).
Usage:move_file(File,Dir)
Move File to directory Dir
Usage:copy_files(Files,Dir)
Like copy_files/3, with empty options list.
Usage:copy_files(Files,Dir,Opts)
Copy Files to directory Dir, using Opts as the option list for copy. See copy_file/3 for the list of options. Note that to move only one file to a directory, rename_file/2 can be used.
Usage:copy_files_nofail(Files,Dir,Opts)
Like copy_files/3, but do not fail in case of errors.
Usage:del_file_nofail(File)
Like delete_file/1, but do not fail in case of errors.
Usage:del_files_nofail(Files)
Like del_file_nofail/1, but takes list of files in Files.
Usage:file_to_line(File,Str)
Usage:replace_strings_in_file(Ss,F1,F2)
Like replace_strings/3 but from file F1 to file F2.
Usage:backup_file(FileName)
Save a backup copy of file FileName
Usage:move_if_diff(From,To,NewOrOld)
If To does not exist, or its contents are different from From, delete To and rename From to To. NewOrOld is unified with new or old depending on whether the new or the old file is preserved.
Usage:set_file_owner(File,Owner)
Set user/group of a file.
Usage:set_file_perms(File,Perms)
Set permissions of File to Perms.
Perms is a term providing valid permissions (``modes'') for User, Group, and Others. These are all valid_mode/1s. Defined as follows:
perms_term(perms(U,G,O)) :- valid_mode(U), valid_mode(G), valid_mode(O).
Usage:perms_term(Perms)
Perms is a term providing modes for User, Group, and Others.
Mode is an atom that provides a valid set of file permissions (a valid ``mode''). Defined as follows:
valid_mode(''). valid_mode('X'). valid_mode(x). valid_mode(w). valid_mode(wX). valid_mode(wx). valid_mode(r). valid_mode(rX). valid_mode(rx). valid_mode(rw). valid_mode(rwX). valid_mode(rwx).
Usage:valid_mode(Mode)
Mode is a file permissions mode.
Usage:set_exec_perms(File,Perms)
Set file permissions, but treat regular files as directories w.r.t. 'X' flag
Usage:mkpath(Path)
Creates the directories necessary to access the given Path (which can be absolute or relative).
Usage:mkpath(Path,Perms)
Like mkpath, but sets permissions of new directories as Perms.
Usage:mkpath(Path,Perms,Owner)
Like mkpath, but sets permissions and owner of new directories to Perms and Owner.
Usage:
Equivalent to mkpath_mode(Path,Mode,_).
Usage:
Equivalent to mkpath_mode(Path,0o777,_).
Usage:mktempdir_in_tmp(Template,Path)
Create a directory in the temporary directory using Template (see mktemp_in_tmp/2). An empty file CREATED_WITH_MKTEMPDIR is created inside Path as a safety check for rmtempdir/1.
Usage:rmtempdir(Path)
Remove the temporary directory Path (recursively) created with mktempdir_in_tmp/2. As a safety check, this predicate throws an exception if the CREATED_WITH_MKTEMPDIR file is not in Path.
Usage:create_rel_link(From,To)
Create a relocatable symlink (computing relative paths) (e.g., /a/b/c (symlink) -> /a/d/e becomes /a/b/c (symlink) -> ../d/e
Usage:create_link(From,To)
Create a symlink from From to To. On platforms where symlinks are not supported (Windows) the file is copied instead. The file To is removed if it existed before.
Usage:relpath(A,B,C)
C is a path to B relative to A (using .. if needed) (e.g., /a/b/c -> /a/d/e becomes /a/b/c -> ../../d/e. Assume both are absolute, otherwise just return B.
Usage:istty(FD)
Check if the file descriptor is associated with a terminal.