Documentation

Init.System.FilePath

A path on the file system.

Paths consist of a sequence of directories followed by the name of a file or directory. They are delimited by a platform-dependent separator character (see System.FilePath.pathSeparator).

  • toString : String

    The string representation of the path.

Instances For

    The character that separates directories.

    On platforms that support multiple separators, System.FilePath.pathSeparator is the “ideal” one expected by users on the platform. System.FilePath.pathSeparators lists all supported separators.

    Equations
      Instances For

        The list of all path separator characters supported on the current platform.

        On platforms that support multiple separators, System.FilePath.pathSeparator is the “ideal” one expected by users on the platform.

        Equations
          Instances For

            The character that separates file extensions from file names.

            Equations
              Instances For

                The file extension expected for executable binaries on the current platform, or "" if there is no such extension.

                Equations
                  Instances For

                    Normalizes a path, returning an equivalent path that may better follow platform conventions.

                    In particular:

                    • On Windows, drive letters are made uppercase.
                    • On platforms that support multiple path separators (that is, where System.FilePath.pathSeparators has length greater than one), alternative path separators are replaced with the preferred path separator.

                    There is no guarantee that two equivalent paths normalize to the same path.

                    Equations
                      Instances For

                        An absolute path starts at the root directory or a drive letter. Accessing files through an absolute path does not depend on the current working directory.

                        Equations
                          Instances For

                            A relative path is one that depends on the current working directory for interpretation. Relative paths do not start with the root directory or a drive letter.

                            Equations
                              Instances For

                                Appends two paths, taking absolute paths into account. This operation is also accessible via the / operator.

                                If sub is an absolute path, then p is discarded and sub is returned. If sub is a relative path, then it is attached to p with the platform-specific path separator.

                                Equations
                                  Instances For

                                    Returns the parent directory of a path, if there is one.

                                    If the path is that of the root directory or the root of a drive letter, none is returned. Otherwise, the path's parent directory is returned.

                                    Equations
                                      Instances For

                                        Extracts the last element of a path if it is a file or directory name.

                                        Returns none if the last entry is a special name (such as . or ..) or if the path is the root directory.

                                        Equations
                                          Instances For

                                            Extracts the stem (non-extension) part of p.fileName.

                                            If the filename contains multiple extensions, then only the last one is removed. Returns none if there is no file name at the end of the path.

                                            Examples:

                                            • ("app.exe" : System.FilePath).fileStem = some "app"
                                            • ("file.tar.gz" : System.FilePath).fileStem = some "file.tar"
                                            • ("files/" : System.FilePath).fileStem = none
                                            • ("files/picture.jpg" : System.FilePath).fileStem = some "picture"
                                            Equations
                                              Instances For

                                                Extracts the extension part of p.fileName.

                                                If the filename contains multiple extensions, then only the last one is extracted. Returns none if there is no file name at the end of the path.

                                                Examples:

                                                • ("app.exe" : System.FilePath).extension = some "exe"
                                                • ("file.tar.gz" : System.FilePath).extension = some "gz"
                                                • ("files/" : System.FilePath).extension = none
                                                • ("files/picture.jpg" : System.FilePath).extension = some "jpg"
                                                Equations
                                                  Instances For

                                                    Replaces the file name at the end of the path p with fname, placing fname in the parent directory of p.

                                                    If p has no parent directory, then fname is returned unmodified.

                                                    Equations
                                                      Instances For

                                                        Appends the extension ext to a path p.

                                                        ext should not have leading ., as this function adds one. If ext is the empty string, no . is added.

                                                        Unlike System.FilePath.withExtension, this does not remove any existing extension.

                                                        Equations
                                                          Instances For

                                                            Replaces the current extension in a path p with ext, adding it if there is no extension. If the path has multiple file extensions, only the last one is replaced. If the path has no filename, or if ext is the empty string, then the filename is returned unmodified.

                                                            ext should not have a leading ., as this function adds one.

                                                            Examples:

                                                            • ("files/picture.jpeg" : System.FilePath).withExtension "jpg" = ⟨"files/picture.jpg"⟩
                                                            • ("files/" : System.FilePath).withExtension "zip" = ⟨"files/"⟩
                                                            • ("files" : System.FilePath).withExtension "zip" = ⟨"files.zip"⟩
                                                            • ("files/archive.tar.gz" : System.FilePath).withExtension "xz" = ⟨"files.tar.xz"⟩
                                                            Equations
                                                              Instances For

                                                                Splits a path into a list of individual file names at the platform-specific path separator.

                                                                Equations
                                                                  Instances For

                                                                    Constructs a path from a list of file names by interspersing them with the current platform's path separator.

                                                                    Equations
                                                                      Instances For
                                                                        @[reducible, inline]
                                                                        Equations
                                                                          Instances For

                                                                            The character that is used to separate the entries in the $PATH (or %PATH%) environment variable.

                                                                            This value is platform dependent.

                                                                            Equations
                                                                              Instances For

                                                                                Separates the entries in the $PATH (or %PATH%) environment variable by the current platform-dependent separator character.

                                                                                Equations
                                                                                  Instances For

                                                                                    Joins a list of paths into a suitable value for the current platform's $PATH (or %PATH%) environment variable.

                                                                                    Equations
                                                                                      Instances For