VirtualFileSystem

public protocol VirtualFileSystem : LuaWrapper, CustomStringConvertible

Represents the file system.

  • Returns true if this file system supports the passed feature.

    Declaration

    Swift

    func hasFeature(_ feature: VirtualFileSystemFeature) -> Bool
  • Returns the parent file for this virtual system, or nil if this is not a nested virtual system.

    Declaration

    Swift

    var parent: VirtualFile? { get }
  • A disposable container.

    Note

    You should not put disposables to LocalFileSystem, as it is never disposed. An error will be thrown if you try to do so.

    Declaration

    Swift

    var disposable: DisposableContainer { get }
  • Returns the file for the path, or nil if the file does not exist of if the path is invalid.

    Note

    A path should not end with a trailing slash (/).

    Declaration

    Swift

    func getFile(at path: String) -> VirtualFile?
  • Iterate through the children of this directory.

    Declaration

    Swift

    func getChildren(in file: VirtualFile, recursively: Bool, mode: FileIterateMode) -> FileIterator

    Parameters

    file

    a directory to iterate.

    recursively

    run the recursive visitor if true.

    mode

    iteration mode.

  • Makes the new directory at path.

    Declaration

    Swift

    func makeDirectory(path: String, mode: mode_t) throws

    Parameters

    path

    an absolute path of the created directory.

    mode

    mode flags of the created directory. Should include S_IFDIR.

  • Deletes the file.

    Declaration

    Swift

    func delete(file: VirtualFile) throws
  • Returns the path with symbolic link resolved. The returned path may be relative.

    Declaration

    Swift

    func readLink(file: VirtualFile) throws -> String
  • Creates a symbolic link pointing to the target (may be relative path).

    Declaration

    Swift

    func makeSymbolicLink(path: String, to target: String) throws

    Parameters

    path

    a link contents (absolute or relative).

    target

    an absolute path of the symbolic link file.

  • Returns true if the file at path exists, false otherwise.

    Declaration

    Swift

    func exists(path: String) -> Bool
  • rename(_:to:overwrite:) Default implementation

    Try to move file efficiently (without copying & deleting).

    Call site should handle the IOError.unsupported error as it is likely to be thrown for a significant number of cases.

    Default Implementation

    Move file efficiently (without copying & deleting) if possible.

    You should handle the IOError.unsupported error as it is likely to be thrown for a significant number of cases.

    Declaration

    Swift

    func rename(_ source: VirtualFile, to target: TargetFile, overwrite: Bool) throws

    Parameters

    source

    a source file.

    target

    a target file.

    overwrite

    overwrite the target if exists.

  • Copies the source file to the target.

    Default Implementation

    Default copyFile implementation. It uses FileInputStream and FileOutputStream to copy the file content.

    This does not copy file attributes or the ACL data.

    Declaration

    Swift

    func copyFile(source: VirtualFile, target: TargetFile, overwrite: Bool, progress: @escaping (Int) -> Bool) throws
  • Opens the input stream for a given file.

    Declaration

    Swift

    func openInputStream(file: VirtualFile) throws -> FileInputStream
  • Opens the output stream for the a given file path.

    Declaration

    Swift

    func openOutputStream(path: String, overwrite: Bool) throws -> FileOutputStream

    Parameters

    overwrite

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

  • flush() Default implementation

    Flushes the pending file system changes. Does nothing if the file system implementation does not support caching.

    Invoked before the file system is deconstructed. You can also call flush() after expensive file operations such as copying, deleting, etc.

    Default Implementation

    Declaration

    Swift

    func flush() throws
  • Returns true if both files are located on the same volume.

    Declaration

    Swift

    func isInSameVolume(_ f: VirtualFile, _ s: VirtualFile) -> Bool
  • getIcon(for:) Default implementation

    Returns a customized icon for the given file, or nil if the default icon is good enough.

    Default Implementation

    Declaration

    Swift

    func getIcon(for file: VirtualFile) -> Icon?
  • makeTarget(_:) Extension method

    Returns a target file with a specified path bound to this file system.

    Declaration

    Swift

    public func makeTarget(_ path: String) -> TargetFile