DirectoryPath

public struct DirectoryPath: Path

The path to either a directory or the symbolic link to a directory.

  • Creates an absolute path to a directory from (but not including) the root folder through all the directories listed in the array. - Parameter components: The names of the directories in the path, in order. Each name must not be empty or contain only a ’.’, and any ’..’ must be at the beginning.

    Declaration

    Swift

    public init(absolute components: [String])

    Parameters

    components

    The names of the directories in the path, in order. Each name must not be empty or contain only a ‘.’, and any ‘..’ must be at the beginning.

  • Creates a relative path to a directory, from the provided base. Each name in the parameter arrays must not be empty or contain only a ’.’, and any ’..’ must be at the beginning. - Parameter base: The names of the directories in the base, in order. - Parameter relative: The names of the directories in the relative part, in order. If empty the path refers to the base directory.

    Declaration

    Swift

    public init(base: [String], relative: [String])

    Parameters

    base

    The names of the directories in the base, in order.

    relative

    The names of the directories in the relative part, in order. If empty the path refers to the base directory.

  • The individual parts of the relative part (if any) of this path. Any ’..’ not at the beginning have been resolved, and there are no empty parts or only ’.’. If this exists, then so do baseComponents.

    Declaration

    Swift

    public var relativeComponents: [String]?
  • The individual parts of the base part (if any) of this path, from (but not including) the root folder. Any ’..’ not at the beginning have been resolved, and there are no empty parts or only ’.’. If this exists, then so do relativeComponents.

    Declaration

    Swift

    public var baseComponents: [String]?
  • The individual parts of the absolute version of this path, from (but not including) the root folder. Any ’..’ not at the beginning have been resolved, and there are no empty parts or only ’.’.

    Declaration

    Swift

    public var components: [String]
  • Returns a Directory object if there is a directory at this path.

    Throws

    FileSystemError.notFound, .notDirectory, .invalidAccess.

    Declaration

    Swift

    public func open() throws -> Directory
  • Creates a new directory at this path.

    Parameter

    Parameter ifExists: What to do if it already exists: open, throw error or replace.

    Returns

    A Directory object with this path.

    Throws

    FileSystemError.notDirectory, .alreadyExists, .outsideSandbox.

    Declaration

    Swift

    public func create(ifExists: AlreadyExistsOptions) throws -> Directory

    Parameters

    ifExists

    What to do if it already exists: open, throw error or replace.

    Return Value

    A Directory object with this path.

  • Creates a path from a string. If the string begins with a ’/’ it is absolute, otherwise it is relative to the current working directory.

    Declaration

    Swift

    public init(extendedGraphemeClusterLiteral value: String)
  • Creates a path from a string. If the string begins with a ’/’ it is absolute, otherwise it is relative to the current working directory.

    Declaration

    Swift

    public init(stringLiteral value: String)
  • Creates a path from a string. If the string begins with a ’/’ it is absolute, otherwise it is relative to the current working directory.

    Declaration

    Swift

    public init(unicodeScalarLiteral value: String)
  • The path to the current working directory.

    Declaration

    Swift

    public static var current: DirectoryPath
  • The path to the current user’s home directory.

    Declaration

    Swift

    public static var home: DirectoryPath
  • The path to the root directory in the local file system.

    Declaration

    Swift

    public static var root: DirectoryPath
  • Adds a file path to the end of this directory path.

    Declaration

    Swift

    public func append(file stringpath: String) -> FilePath
  • Adds a directory path to the end of this directory path.

    Declaration

    Swift

    public func append(directory stringpath: String) -> DirectoryPath
  • Undocumented

    Declaration

    Swift

    public struct DirectoryPath: Path
  • Checks if the absolute version of the provided path begins with the absolute version of this path.

    Declaration

    Swift

    public func isAParentOf<P: Path>(_ path: P) -> Bool
  • Declaration

    Swift

    public static func ==(left: DirectoryPath, right: DirectoryPath) -> Bool

    Parameters

    lhs

    A value to compare.

    rhs

    Another value to compare.