Represents a root of a file path.
On Unix, a root is simply the directory separator `/`.
On Windows, a root contains the entire path prefix up to and including
the final separator.
Examples:
* Unix:
* `/`
* Windows:
* `C:\`
* `C:`
* `\`
* `\\server\share\`
* `\\?\UNC\server\share\`
* `\\?\Volume{12345678-abcd-1111-2222-123445789abc}\`
Members (10)
get · iOS 15.0+
description
TypeScript
get description(): string
Swift declaration
var description: String { get }
A textual representation of the path root.
If the content of the path root isn't a well-formed Unicode string,
this replaces invalid bytes with U+FFFD. See `String.init(decoding:)`.
Creates a file path root by copying bytes from a null-terminated platform
string.
Returns `nil` if `platformString` is empty or is not a root.
- Parameter platformString: A pointer to a null-terminated platform
string.
Creates a file path root by copying bytes from a null-terminated platform
string. It is a precondition that a null byte indicates the end of
the string. The absence of a null byte will trigger a runtime error.
Returns `nil` if `platformString` is empty or is not a root.
- Note It is a precondition that `platformString` must be null-terminated.
The absence of a null byte will trigger a runtime error.
- Parameter platformString: A null-terminated platform string.
Omit the output parameters from the call. The result contains $ret and $out, with platformString inside $out.
get · iOS 15.0+
debugDescription
TypeScript
get debugDescription(): string
Swift declaration
var debugDescription: String { get }
A textual representation of the path root, suitable for debugging.
If the content of the path root isn't a well-formed Unicode string,
this replaces invalid bytes with U+FFFD. See `String.init(decoding:)`.
func withPlatformString<Result>(_ body: (UnsafePointer<CInterop.PlatformChar>) throws -> Result) rethrows -> Result
Calls the given closure with a pointer to the contents of the file path
root, represented as a null-terminated platform string.
If the path has a relative portion, an allocation will occur in order to
add the null terminator.
- Parameter body: A closure with a pointer parameter
that points to a null-terminated platform string.
If `body` has a return value,
that value is also used as the return value for this method.
- Returns: The return value, if any, of the `body` closure parameter.
The pointer passed as an argument to `body` is valid
only during the execution of this method.
Don't try to store the pointer for later use.
get · iOS 15.0+
string
TypeScript
get string(): string
Swift declaration
var string: String { get }
On Unix, this returns `"/"`.
On Windows, interprets the root's content as UTF-16 on Windows.
This property is equivalent to calling `String(decoding: root)`.