VirtualFile

public protocol VirtualFile : TargetFile, CustomStringConvertible

Represents the file in the virtual file system.

  • The file system that contains this file.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    var simpleName: String { get }
  • isHidden Default implementation

    True if the file is hidden.

    Default Implementation

    True if the file is hidden.

    Declaration

    Swift

    var isHidden: Bool { get }
  • The file size in bytes.

    Declaration

    Swift

    var size: Int { get }
  • The date when the file was created (timestamp).

    Declaration

    Swift

    var dateCreated: Int { get }
  • The date when the file was modified (timestamp).

    Declaration

    Swift

    var dateModified: Int { get }
  • The date when the file was added to the parent directory (timestamp).

    Declaration

    Swift

    var dateAdded: Int { get }
  • The file mode.

    Declaration

    Swift

    var mode: mode_t { get }
  • Checks if other is the same file.

    Declaration

    Swift

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

    Declaration

    Swift

    public var description: String { get }
  • getParent() Extension method

    @Lua

    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 { get }
  • isFile Extension method

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

    Declaration

    Swift

    public var isFile: Bool { get }
  • isDirectory Extension method

    True if the file is a directory.

    Declaration

    Swift

    public var isDirectory: Bool { get }
  • isSymbolicLink Extension method

    True if the file is a symbolic link.

    Declaration

    Swift

    public var isSymbolicLink: Bool { get }
  • 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 { get }
  • simpleNameWithoutExtension Extension method

    Returns the file name without its extension.

    Declaration

    Swift

    public var simpleNameWithoutExtension: String { get }
  • 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
  • readLinkTarget() Extension method

    Returns the target file with a symbolic links or alias resolved.

    Declaration

    Swift

    public func readLinkTarget() throws -> TargetFile
  • toTarget() Extension method

    Converts this file to a TargetFile instance.

    Declaration

    Swift

    public func toTarget() -> TargetFile
  • isInSameVolume(with:) Extension method

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

    Declaration

    Swift

    public func isInSameVolume(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
  • getChildren() Extension method

    Returns the immediate children of this directory.

    Declaration

    Swift

    public func getChildren() -> FileIterator
  • relativePathTo(base:) Extension method

    Returns the path relative to the base file.

    Declaration

    Swift

    public func relativePathTo(base: VirtualFile) -> String?
  • Caches the file synchronously.

    See also: cache() and cacheFiles().

    Declaration

    Swift

    public func cacheSynchronously(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).