VirtualFileSystem

public protocol VirtualFileSystem : class

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?
  • A disposable container.

    Note that 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
  • Returns the file for the path, or nil if the file does not exist of if the path is invalid.

    Note: File 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

    recursively

    If true, the children files will be returned recursively. If false, only the immediate children will be returned.

  • Makes the new directory at path.

    Declaration

    Swift

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

    Parameters

    mode

    the mode for the newly created directory. Should include S_IFDIR flag.

  • Deletes the file.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    func makeSymbolicLink(path: String, to target: String) throws
  • 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).

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

    Default Implementation

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

    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
  • Opens the input stream for the given file.

    Declaration

    Swift

    func openInputStream(file: VirtualFile) throws -> FileInputStream
  • Opens the output stream for the the 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

    Write the cached changes, and empty the internal file system caches.

    This is typically invoked before the file system is deconstructed. You may also call flush() after heavy file operations (copying, deleting, etc.)

    Default Implementation

    Declaration

    Swift

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

    Declaration

    Swift

    func isTheSameVolume(_ f: VirtualFile, _ s: VirtualFile) -> Bool
  • Default copyFile implementation which uses FileInputStream and FileOutputStream to copy the file.

    It does not copy the file attributes or ACL information.

    Declaration

    Swift

    func copyFile(
                source: VirtualFile,
                target: TargetFile,
                overwrite: Bool,
                progress: @escaping (Int) -> Bool
        ) throws
  • getChildren(in:) Extension method

    Get the immediate children of this directory .

    Declaration

    Swift

    func getChildren(in file: VirtualFile) -> FileIterator