# OS:Path

### Import List

        Object
        Object

Procedure Summary
BaseName(STRING): STRING Calculates the basename of pathname path.
Decode(ARRAY OF CHAR): STRING Convert a system-specific sequence of bytes path representing a file path into a string instance.
DirName(STRING): STRING Calculates the directory name of pathname path.
Encode(STRING): CharsLatin1 Encode the file path or command path as a system-specific sequence of bytes.
QuoteForShell(STRING): STRING Convert a path to a form suitable for passing as a command-line argument to a system command.
SplitExt(STRING, VAR STRING, VAR STRING) Splits the pathname path into a pair ``(root, ext)`' such that ``concat(root,ext) = path`'.

Procedure Detail

### BaseName

    PROCEDURE BaseName(path: STRING): STRING

> Calculates the basename of pathname path. The basename is the last pathname component of path. It never contains a slash. If path ends with a slash, then the basename is the empty string. If path does not contain a slash, then the basename equals path.

### Decode

    PROCEDURE Decode(path: ARRAY OF CHAR): STRING

> Convert a system-specific sequence of bytes path representing a file path into a string instance. This is the inverse of Encode.

### DirName

    PROCEDURE DirName(path: STRING): STRING

> Calculates the directory name of pathname path.

### Encode

    PROCEDURE Encode(path: STRING): CharsLatin1

> Encode the file path or command path as a system-specific sequence of bytes.

> The default implementation returns a string with all character codes above ``0FFX`' replaced with the character ``_`'. That is, non ISO Latin1 characters are discarded. For instances of Object.String8, it is the identity operation.

### QuoteForShell

    PROCEDURE QuoteForShell(path: STRING): STRING

> Convert a path to a form suitable for passing as a command-line argument to a system command. Certain characters cannot be directly used in command-line path arguments because the characters have special significance to the system shell. For example, spaces are used to separate arguments in command lines, so a path containing spaces must be quoted to cause the shell to treat it as a literal.

> This function determines if path needs to be quoted. If so, it returns a quoted version. Otherwise, the original path is returned.

### SplitExt

    PROCEDURE SplitExt(path: STRING;
                       VAR root: STRING;
                       VAR ext: STRING)

> Splits the pathname path into a pair ``(root, ext)`' such that ``concat(root,ext) = path`'. The extension ext is empty or begins with a period and contains at most one period. The extension string does not contain a slash character.