Relationship

  • Return the relative location of path from the current working directory. Example: starting from /Users/dan, the relative path of / would be ../...

    Throws

    system error resulted from trying to access current working directory.

    See also

    To work with Path or PathRepresentable, use PathRepresentable.relativePath.

    Declaration

    Swift

    public func relativePath(ofPath path: String) throws -> String

    Parameters

    path

    the path the result is relative to.

    Return Value

    a relative file path to current working directory.

  • Return the argument with an initial component of ~ or ~user replaced by that user’s home directory.

    Declaration

    Swift

    public func expandUserDirectory(inPath path: String) throws -> String

    Parameters

    path

    The path whose initial component is to be expanded.

  • Return relative location of path from from an another location. This is a pure computation: the filesystem is not accessed to confirm the existence or nature of path or startingPath. Example: starting from /Users/dan, the relative path of / would be ../...

    Declaration

    Swift

    public func relativePath(ofPath path: String, startingFromPath startingPath: String) -> String

    Parameters

    path

    the path the result is relative to.

    startingPath

    starting path of the relativity.

    Return Value

    a relative file path to path.

  • Return the longest common sub-path of each given argument. Segment of sub-path is the smallest unit of commonality, meaning this is different from common string prefix: /usr/lib and /usr/lib64‘s common path is /usr as opposed to /usr/lib.

    Declaration

    Swift

    public func commonPath(amongPaths firstPath: String, _ secondPath: String, _ otherPaths: String...) -> String

    Parameters

    firstPath

    First path. This parameter ensures there are at least 2 paths to compare.

    secondPath

    Second path. This parameter ensures there are at least 2 paths to compare.

    otherPaths

    Other, optional paths.

    Return Value

    The longest common sub-path of each given argument.

  • See also

    To work with Path or PathRepresentable, use PathRepresentable.join(with:).

    Declaration

    Swift

    public func join(paths: [String]) -> String
  • See also

    To work with Path or PathRepresentable, use PathRepresentable.join(with:_:).

    Declaration

    Swift

    public func join(paths firstPath: String, _ secondPath: String, _ otherPaths: String...) -> String
  • Syntax sugar for joining two PathRepresentables.

    Declaration

    Swift

    public func + <T>(lhs: T, rhs: T) -> T where T : PathRepresentable