VirtualFile

public protocol VirtualFile : class, TargetFile

Represents the file in the virtual file system.

  • The file system that contains this file.

    Declaration

    Swift

    var fileSystem: VirtualFileSystem
  • The absolute path of this file (local for it’s file system).

    Declaration

    Swift

    var absolutePath: String
  • The simple name of this file with an extension.

    Declaration

    Swift

    var simpleName: String
  • isHidden Default implementation

    True if the file is hidden.

    Default Implementation

    True if the file is hidden.

    Declaration

    Swift

    var isHidden: Bool
  • icon Default implementation

    The icon for the file.

    Default Implementation

    Declaration

    Swift

    var icon: NSImage?
  • The file stat information (size, date, etc.).

    Declaration

    Swift

    var stat: VirtualFileStat
  • Checks if other is the same file.

    Declaration

    Swift

    func equals(_ other: Any?) -> Bool
  • getParent() Extension method

    Returns the parent of this file, or nil if the file is root or the immediate parent directory does not exist anymore.

    Declaration

    Swift

    public func getParent() -> VirtualFile?
  • isRoot Extension method

    True if the file is a root (‘/’) file for this file system.

    Declaration

    Swift

    public var isRoot: Bool
  • isFile Extension method

    True if the file is a regular file (not a directory or a symbolic link).

    Declaration

    Swift

    public var isFile: Bool
  • isDirectory Extension method

    True if the file is a directory.

    Declaration

    Swift

    public var isDirectory: Bool
  • isSymbolicLink Extension method

    True if the file is a symbolic link.

    Declaration

    Swift

    public var isSymbolicLink: Bool
  • size Extension method

    The size of the file (the same as stat.size).

    Declaration

    Swift

    public var size: Int
  • fileExtension Extension method

    Returns the file extension, or an empty String if the file does not have an extension.

    Declaration

    Swift

    public var fileExtension: String
  • simpleNameWithoutExtension Extension method

    Returns the file name without its extension.

    Declaration

    Swift

    public var simpleNameWithoutExtension: String
  • openInputStream() Extension method

    Opens the input stream for the this file.

    Declaration

    Swift

    public func openInputStream() throws -> FileInputStream
  • openOutputStream(overwrite:) Extension method

    Opens the output stream for the this file.

    Declaration

    Swift

    public func openOutputStream(overwrite: Bool) throws -> FileOutputStream

    Parameters

    overwrite

    if false, IOError.fileExists will be thrown if the file does already exist.

  • readLink() Extension method

    Returns the path with symbolic link or alias resolved. THe returned path may be relative.

    Declaration

    Swift

    public func readLink() throws -> String
  • isTheSameVolume(with:) Extension method

    Returns true if both files are located on the same volume.

    Declaration

    Swift

    public func isTheSameVolume(with other: VirtualFile) -> Bool
  • delete() Extension method

    Deletes the file.

    Declaration

    Swift

    public func delete() throws
  • copy(to:overwrite:progress:) Extension method

    Copies the file to target.

    Declaration

    Swift

    public func copy(to target: TargetFile, overwrite: Bool, progress: @escaping (Int) -> Bool = { _ in true }) throws
  • Caches the file synchronously.

    See also: cache() and cacheFiles().

    Declaration

    Swift

    public func cacheSynchronously(
                _ globalContext: GlobalContext,
                progress: @escaping (Int) -> Bool
        ) throws -> TempFile
  • cache(_:onComplete:) Extension method

    Cache this file asynchronously with the progress window.

    Note that onComplete is not called if the caching was cancelled by user.

    Declaration

    Swift

    public func cache(_ context: WeakActionContext, onComplete: @escaping (Result<LocalFile>) -> ())

    Parameters

    files

    the files to cache. Some of them may be local, they won’t be cached.

    context

    an action context.

    onComplete

    handler to call when the caching is complete (or there was an error).