Existence

  • Return true if path refers to an existing path or an open file descriptor. On some platforms, this function may return false if permission is not granted to execute stat on the requested file, even if the path physically exists.

    Declaration

    Swift

    public func exists(atPath path: String, followSymbol: Bool = true) -> Bool

    Parameters

    path

    the path to be tested.

    followSymbol

    whether to follow symbolic links. If true, return false for broken symbolic links.

    Return Value

    whether path refers to an existing path or an open file descriptor.

  • Whether file at path is of a type. Returns false if the path does not exist or is not accessible.

    Declaration

    Swift

    public func isA(_ type: FileType, atPath path: String) throws -> Bool

    Parameters

    type

    The type in question. See FileType.

  • Return whether path points to the same file as otherPath.

    Throws

    A SystemError if either path cannot be accessed for some reason.

    See also

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

    Declaration

    Swift

    public func sameFile(atPath path: String, otherPath: String) throws -> Bool

    Parameters

    path

    the first path in comparison.

    otherPath

    the other path in comparison.

    Return Value

    whether the 2 paths points to the same file.

  • Type of files found in standards such as POSIX. NOTE: a directory is a type of file as everything else.

    See more

    Declaration

    Swift

    public enum FileType : Int, Equatable, Codable