Additional operating system utilities

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

A convenient extension to library system

Documentation on exports

PREDICATE

Usage:-G

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

    Meta-predicate with arguments: -goal.

    PREDICATE

    Usage:--G

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

      Meta-predicate with arguments: --goal.

      PREDICATE

      Usage:try_finally(Start,Goal,End)

      Calls initialization goal Start and then calls Goal Goal, but always continues with the evaluation of End. If Goal is non-deterministic, in case of backtracking Start is called again before redoing Goal.

        Meta-predicate with arguments: try_finally(goal,goal,goal).

        PREDICATE
        No further documentation available for this predicate.

        PREDICATE

        Usage:empty_dir(D)

        D is an empty directory

          PREDICATE

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

            (True) Usage 2:

            • The following properties should hold at call time:
              (basic_props:list/2)Arg1 is a list of atms.
              (basic_props:atm/1)Arg2 is an atom.

            PREDICATE

            Usage:move_file(File,Dir)

            Move File to directory Dir

              PREDICATE

              Usage 1:copy_files(Files,Dir)

              Like copy_files/3, with empty options list.

                (True) Usage 2:

                • The following properties should hold at call time:
                  (basic_props:list/2)Arg1 is a list of atms.
                  (basic_props:atm/1)Arg2 is an atom.

                PREDICATE

                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.

                  PREDICATE

                  Usage:copy_files_nofail(Files,Dir,Opts)

                  Like copy_files/3, but do not fail in case of errors.

                    PREDICATE
                    No further documentation available for this predicate.

                    PREDICATE
                    No further documentation available for this predicate.

                    PREDICATE
                    No further documentation available for this predicate.

                    PREDICATE
                    No further documentation available for this predicate.

                    PREDICATE

                    Usage:backup_file(FileName)

                    Save a backup copy of file FileName

                      PREDICATE

                      Usage:move_if_diff(From,To)

                      If To does not exists of its contents are different than From, delete To and rename From to To. Otherwise remove From and fail.

                        PREDICATE

                        Usage:set_file_owner(File,Owner)

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

                          PREDICATE

                          Usage:set_file_perms(File,Perms)

                          Set file permissions.

                            PREDICATE

                            Usage:set_exec_perms(File,Perms)

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

                              PREDICATE

                              Usage:mkpath(Path)

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

                              • The following properties should hold at call time:
                                (streams_basic:sourcename/1)Path is a source name.

                              PREDICATE

                              Usage:mkpath(Path,Perms)

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

                              • The following properties should hold at call time:
                                (streams_basic:sourcename/1)Path is a source name.
                                (basic_props:term/1)Perms is any term.

                              PREDICATE

                              Usage:mkpath(Path,Perms,Owner)

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

                              • The following properties should hold at call time:
                                (streams_basic:sourcename/1)Path is a source name.
                                (basic_props:term/1)Perms is any term.
                                (basic_props:term/1)Owner is any term.

                              PREDICATE
                              No further documentation available for this predicate.

                              PREDICATE

                              Usage:

                              Equivalent to mkpath_mode(Path,Mode,_).

                              • The following properties should hold at call time:
                                (streams_basic:sourcename/1)Arg1 is a source name.
                                (basic_props:int/1)Arg2 is an integer.

                              PREDICATE

                              Usage:

                              Equivalent to mkpath_mode(Path,0o777,_).

                              • The following properties should hold at call time:
                                (streams_basic:sourcename/1)Arg1 is a source name.

                              PREDICATE

                              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.

                                PREDICATE

                                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.

                                  PREDICATE

                                  Usage:

                                  The standard input is an interactive terminal.

                                    PREDICATE
                                    No further documentation available for this predicate.

                                    PREDICATE
                                    No further documentation available for this predicate.

                                    PREDICATE
                                    No further documentation available for this predicate.

                                    PREDICATE
                                    No further documentation available for this predicate.

                                    PREDICATE
                                    No further documentation available for this predicate.

                                    PREDICATE
                                    No further documentation available for this predicate.

                                    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.