WebURL Documentation Beta

Structure URLFrom​File​Path​Error

public struct URLFromFilePathError: Error, Equatable, Hashable, CustomStringConvertible 

The reason why a file URL could not be created from a given file path.

Conforms To

CustomStringConvertible
Equatable
Error
Hashable

Properties

empty​Input

@inlinable
public static var emptyInput: URLFromFilePathError 

The given path is empty.

null​Bytes

@inlinable
public static var nullBytes: URLFromFilePathError 

The given path contains ASCII NULL bytes.

NULL bytes are forbidden, to protect against injected truncation.

relative​Path

@inlinable
public static var relativePath: URLFromFilePathError 

The given path is not absolute/fully-qualified.

Each path format has different kinds of relative paths. Use APIs provided by the platform, or the swift-system library, to resolve the input as an absolute path. Be advised that some kinds of relative path resolution may not be thread-safe; consult your chosen path API for details.

upwards​Traversal

@inlinable
public static var upwardsTraversal: URLFromFilePathError 

The given path contains one or more .. components.

These components are forbidden, to protect against directory traversal attacks. Use APIs provided by the platform, or the swift-system library, to resolve the path. Users are advised to check that the path has not escaped the expected area of the filesystem after it has been resolved.

invalid​Hostname

@inlinable
public static var invalidHostname: URLFromFilePathError 

The given path refers to a file on a remote host, but the hostname is not valid or cannot be represented in a URL.

Note that currently, only ASCII domains, IPv4, and IPv6 addresses are supported. Domains may not include forbidden host code-points.

invalid​Path

@inlinable
public static var invalidPath: URLFromFilePathError 

The given path is ill-formed, prohibiting a URL representation from being formed.

Some FilePathFormats have sub-formats with particular requirements, which may be necessary in order to decide which kind of URL to form. For instance, Win32 file namespace paths (a.k.a. "long" paths) require a device component following the \\?\ prefix.

Examples of invalid Win32 file namespace paths:

  • \\?\ (no path following prefix)

  • \\?\\ (device name is empty)

  • \\?\C: (no trailing slash after device name)

  • \\?\UNC (no trailing slash after device name)

unsupported​Win32Namespaced​Path

@inlinable
public static var unsupportedWin32NamespacedPath: URLFromFilePathError 

The given path is a Win32 file namespace path (a.k.a. "long" path), but references an object for which a URL representation cannot be formed.

Win32 file namespace paths have a variety of ways to reference files - for instance, both \\?\BootPartition\Users\ and \\?\HarddiskVolume2\Users\ might resolve to \\?\C:\Users\. These more exotic paths are currently not supported.

Win32 file namespace paths are documented as opting-out from typical path normalization, meaning that characters such as forward slashes represent literal slashes in a file or directory name. Some Windows APIs respect this, while others do not, meaning that these characters are ambiguous and can potentially lead to security vulnerabilities via smuggled path components. For this reason, they are not supported.

transcoding​Failure

@inlinable
public static var transcodingFailure: URLFromFilePathError 

Transcoding the given path for inclusion in a URL failed.

File URLs can preserve the precise bytes of their path components by means of percent-encoding. However, when the platform's native path representation uses non-8-bit code-units, those elements must be transcoded to an 8-bit encoding suitable for percent-encoding.

description

public var description: String