WebURL Documentation Beta

Structure File​Path​Format

public struct FilePathFormat: Equatable, Hashable, CustomStringConvertible 

A description of a file path's structure.

Conforms To

CustomStringConvertible
Equatable
Hashable

Properties

posix

@inlinable
public static var posix: FilePathFormat 

A path which is compatible with the POSIX standard.

Format

The format and interpretation of POSIX-style paths is documented by IEEE Std 1003.1.

Code Units

The path separator is / (code-unit value 0x2F), and the current/parent directory is represented by ./.. respectively (where . is the code-unit with value 0x2E). All other code-units are not defined and must be preserved exactly.

Normalization

Consecutive separators have the same meaning as a single separator, except if the path starts with exactly 2 separators.

windows

@inlinable
public static var windows: FilePathFormat 

A path which is compatible with those used by Microsoft Windows.

Format

There are many, many Windows path formats. This object represents the most common ones:

  • DOS paths: C:\Users\Alice\Desktop\family.jpg

  • UNC paths: \\us-west.example.com\files\meeting-notes-june.docx

  • DOS long paths: \\?\C:\Users\Bob\Documents\...

  • UNC long paths: \\?\UNC\europe.example.com\jim\...

The precise format and interpretation of these paths is documented by Microsoft:

Code Units

The code-units of Windows file paths natively represent Unicode code-points. Windows provides APIs which encode these paths using either UTF-16 code-units, or ANSI code-units in the system's active code-page (a form of extended ASCII). In either case, the numeric values of code-units in the ASCII range may be interpreted as ASCII characters. File and directory names are not normalized, so the sequence of Unicode code-points must be preserved exactly.

The preferred path separator is \ (code-unit value 0x5C), although some formats also accept / (0x2F). The current/parent directory is represented by ./.. respectively (where . is the code-unit with value 0x2E).

Non-ASCII code-units in path components are treated as opaque. An exception is UNC paths, where the hostname component must be UTF-8.

Normalization

Consecutive separators have the same meaning as a single separator, except if the path starts with exactly 2 separators. Trailing ASCII periods and spaces may be trimmed from path components - a file named foo. cannot be expressed using regular DOS paths. Long paths are not normalized, so they can express the file name foo.. However, many Windows APIs will normalize them regardless.

See File path formats on Windows systems for a description of Windows' path normalization procedure.

native

@inlinable
public static var native: FilePathFormat 

The native path style used by the current operating system.

description

public var description: String