Additional operating system utilities

Author(s): Manuel Hermenegildo, Jose F. Morales.

A convenient extension to library system

Documentation on exports

Usage:warn_on_nosuccess(G)

Call G (cut solutions) and show warning messages if something went wrong (failure and exceptions).

    Meta-predicate with arguments: warn_on_nosuccess(goal).

    Usage:ignore_nosuccess(G)

    Call G and ignore if something went wrong (failure and exceptions).

      Meta-predicate with arguments: ignore_nosuccess(goal).

      No further documentation available for this predicate.

      PREDICATEempty_dir/1

      Usage:empty_dir(D)

      D is an empty directory

        PREDICATEmove_files/2

        Usage 1: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 2:

          PREDICATEmove_file/2

          Usage:move_file(File,Dir)

          Move File to directory Dir

            PREDICATEcopy_files/2

            Usage 1:copy_files(Files,Dir)

            Like copy_files/3, with empty options list.

              Usage 2:

              PREDICATEcopy_files/3

              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.

                  No further documentation available for this predicate.

                  No further documentation available for this predicate.

                  No further documentation available for this predicate.

                  No further documentation available for this predicate.

                  PREDICATEbackup_file/1

                  Usage:backup_file(FileName)

                  Save a backup copy of file FileName

                    Usage:move_if_diff(From,To,NewOrOld)

                    If To does not exists of its contents are different than From, delete To and rename From to To. NewOrOld is unified with new or old depending on whether the new or the old file are preserved.

                      Usage:set_file_owner(File,Owner)

                      Set user/group of a file. Do nothing if Owner is free.

                        Usage:set_file_perms(File,Perms)

                        Set file permissions.

                          Usage:set_exec_perms(File,Perms)

                          Set file permissions, but treat regular files as directories w.r.t. 'X' flag

                            PREDICATEmkpath/1

                            Usage:mkpath(Path)

                            Creates the directories necessary to access the given Path (which can be absolute or relative).

                            PREDICATEmkpath/2

                            Usage:mkpath(Path,Perms)

                            Like mkpath, but sets permissions of new directories as Perms.

                            PREDICATEmkpath/3

                            Usage:mkpath(Path,Perms,Owner)

                            Like mkpath, but sets permissions and owner of new directories to Perms and Owner.

                            PREDICATEmkpath_mode/3
                            No further documentation available for this predicate.

                            PREDICATEmkpath_mode/2

                            Usage:

                            Equivalent to mkpath_mode(Path,Mode,_).

                            PREDICATEmkpath_mode/1

                            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.

                              PREDICATErmtempdir/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

                                  PREDICATEcreate_link/2

                                  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.

                                    PREDICATErelpath/3

                                    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.

                                      PREDICATEusing_tty/0

                                      Usage:

                                      The standard input is an interactive terminal.

                                        PREDICATEdatime_atom/1
                                        No further documentation available for this predicate.

                                        PREDICATEdatime_atom/2
                                        No further documentation available for this predicate.

                                        No further documentation available for this predicate.

                                        No further documentation available for this predicate.

                                        No further documentation available for this predicate.

                                        No further documentation available for this predicate.

                                        Documentation on imports

                                        This module has the following direct dependencies:

                                        Known bugs and planned improvements

                                        • Much of this should probably end up eventually in system, but once we have worked out the best interface and, in some cases, the proper implementation (the implementations in here are in some cases just calls to Unix shell primitives or commands).
                                        • All those predicates (including system too) use atoms to represent file names. This pollutes the atom table. We need atom garbage collection and/or native strings.