[ Operating System | Reference Manual | Alphabetic Index ]

# pathname(+FilePath, -Path, -BaseName, -Suffix)

Decomposes a filename into its directory path, base name and suffix

FilePath
  String or atom.
Path
  Variable or string.
BaseName
  Variable or string.
Suffix
  Variable or string.

## Description

This predicate is used to decompose FilePath which is either a relative or absolute pathname of a file, into three components, namely the pathname of its parent directory including the trailing "/" if any, the `base' name of the file (the plain file name without the suffix), and the suffix, if any. The concatenation of Path, BaseName and Suffix yields the original filename FilePath.

### Modes and Determinism

- pathname(+, -, -, -) is det

### Exceptions

(4) instantiation fault
  FilePath is not instantiated.
(5) type error
  FilePath is neither a string nor an atom.
(5) type error
  Path, BaseName or Suffix is neither a string nor a variable.

## Examples

    Success:

         [eclipse]: pathname("/home/user/userfile.pl", P, B, S).

         P = "/home/user/"
         B = "userfile"
         S = ".pl"
         yes.

          [eclipse]: pathname("/home/user/userfile", P, B, S).
          P = "/home/user/"
          B = "userfile"
          S = ""
          yes.

    Fail:
          pathname("/home/file.pl","/home/","file", "pl").

    Error:
          pathname(F,P,R,S).                 (Error 4).
          pathname("/home/file.pl",P,file,'.pl')    (Error 5).

## See Also

pathname / 3, split_string / 4, join_string / 3, canonical_path_name / 2