One Logo Pool Ball
System · IOS API REFERENCE

FilePath.Component

struct · iOS 15.0+ · SDK 27.1

struct Component

Represents an individual, non-root component of a file path. Components can be one of the special directory components (`.` or `..`) or a file or directory name. Components are never empty and never contain the directory separator. Example: var path: FilePath = "/tmp" let file: FilePath.Component = "foo.txt" file.kind == .regular // true file.extension // "txt" path.append(file) // path is "/tmp/foo.txt"

Members (13)

get · iOS 15.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of the path component. If the content of the path component isn't a well-formed Unicode string, this replaces invalid bytes with U+FFFD. See `String.init(decoding:)`.

init · iOS 15.0+

init

TypeScript
static initStringLiteral(stringLiteral: string): FilePath_Component
Swift declaration
init(stringLiteral: String)

Create a file path component from a string literal. Precondition: `stringLiteral` is non-empty, is not a root, and has only one component in it.

init · iOS 15.0+

init

TypeScript
static initPlatformString(platformString: SDKHandle): (FilePath_Component) | null
Swift declaration
init?(platformString: UnsafePointer<CInterop.PlatformChar>)

Creates a file path component by copying bytes from a null-terminated platform string. Returns `nil` if `platformString` is empty, is a root, or has more than one component in it. - Parameter platformString: A pointer to a null-terminated platform string.

init · iOS 15.0+

init

TypeScript
static initPlatformString9538(platformString: string): (FilePath_Component) | null
Swift declaration
init?(platformString: String)
init · iOS 15.0+

init

TypeScript
static initPlatformString20462(platformString: Array<number>): (FilePath_Component) | null
Swift declaration
init?(platformString: [CInterop.PlatformChar])

Creates a file path component 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, is a root, or has more than one component in it. - 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.

init · iOS 15.0+

init

TypeScript
static initPlatformString57144(platformString: number): { $ret: (FilePath_Component) | null; $out: { "platformString": number } }
Swift declaration
init?(platformString: inout CInterop.PlatformChar)

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 component, suitable for debugging. If the content of the path component isn't a well-formed Unicode string, this replaces invalid bytes with U+FFFD. See `String.init(decoding:)`.

method · iOS 15.0+

withPlatformString

TypeScript
withPlatformString(body: ((arg0: SDKHandle) => unknown)): unknown
Swift declaration
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 component, represented as a null-terminated platform string. If this is not the last component of a path, 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+

kind

TypeScript
get kind(): FilePath_Component_Kind
Swift declaration
var kind: FilePath.Component.Kind { get }

The kind of this component

get · iOS 15.0+

stem

TypeScript
get stem(): string
Swift declaration
var stem: String { get }

The non-extension portion of this file or directory component. Examples: * `foo.txt => foo` * `foo.tar.gz => foo.tar` * `Foo.app => Foo` * `.hidden => .hidden` * `.. => ..`

get · iOS 15.0+

string

TypeScript
get string(): string
Swift declaration
var string: String { get }

Creates a string by interpreting the component’s content as UTF-8 on Unix and UTF-16 on Windows. This property is equivalent to calling `String(decoding: component)`.

get · iOS 15.0+

extension

TypeScript
get extension(): (string) | null
Swift declaration
var `extension`: String? { get }

The extension of this file or directory component. If `self` does not contain a `.` anywhere, or only at the start, returns `nil`. Otherwise, returns everything after the dot. Examples: * `foo.txt => txt` * `foo.tar.gz => gz` * `Foo.app => app` * `.hidden => nil` * `.. => nil`

init · iOS 15.0+

init

TypeScript
static init(string: string): (FilePath_Component) | null
Swift declaration
init?(_ string: String)

Create a file path component from a string. Returns `nil` if `string` is empty, a root, or has more than one component in it.

Skipped declarations

No declarations were skipped in this snapshot.

All System types →