Pike v8.1 release 6

Method System.normalize_path()


Method normalize_path

string normalize_path(string path)

Description

Normalize an existing Windows file system path.

The following transformations are currently done:

  • Forward slashes ('/') are converted to backward slashes ('\').

  • Trailing slashes are removed, except a single slash after a drive letter (e.g. "C:\" is returned instead of "C:").

  • Extraneous empty extensions are removed.

  • Short filenames are expanded to their corresponding long variants.

  • Relative paths are expanded to absolute paths.

  • Current- and parent-directory path components ("." and "..") are followed, similar to combine_path.

  • Case-information in directory and file names is restored.

  • Drive letters are returned in uppercase.

  • The host and share parts of UNC paths are returned in lowercase.

Returns

A normalized absolute path without trailing slashes.

Throws errors on failure, e.g. if the file or directory doesn't exist.

Note

File fork information is currently not supported (invalid data).

Note

In Pike 7.6 and earlier, this function didn't preserve a single slash after drive letters, and it didn't convert the host and share parts of an UNC path to lowercase.

See also

combine_path(), combine_path_nt()