Working Directory

  • Get current working directory.

    Throws

    System error that could trigger when a component of the current path no longer exists or the process lacks permission to read it.

    Declaration

    Swift

    public func getCurrentWorkingDirectory() throws -> String

    Return Value

    Path for current working directory.

  • Set current working directory.

    Throws

    System error that could trigger when, for example, search permission is denied for any component of the path name; There’s a symbolic link loop among some components; A component is not an directory, etc.

    Declaration

    Swift

    public func setCurrentWorkingDirectory(toPath path: String) throws

    Return Value

    Path for current working directory.

  • Execute a closure with the current working direcotry being the specified path. Restore the current working directory when the execution is finished.

    The closure is guaranteed to be invoked synchronously.

    Throws

    Errors encountered setting or reading working directories.

    Declaration

    Swift

    public func withWorkingDirectory(beingPath path: String, performAction closure: @escaping () throws -> Void) throws

    Parameters

    path

    The path that would be the current working directory.

    closure

    The closure that will be called with path being the working directory.