VirtualFile
public protocol VirtualFile : AnyObject, 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 implementationTrue if the file is hidden.
Default Implementation
True if the file is hidden.
Declaration
Swift
var isHidden: Bool { get }
-
icon
Default implementationThe icon for the file.
Default Implementation
Declaration
Swift
var icon: NSImage? { get }
-
The file stat information (size, date, etc.).
Declaration
Swift
var stat: VirtualFileStat { get }
-
Checks if
other
is the same file.Declaration
Swift
func equals(_ other: Any?) -> Bool
-
description
Extension methodDeclaration
Swift
public var description: String { get }
-
getParent()
Extension methodReturns 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 methodTrue if the file is a root (‘/’) file for this file system.
Declaration
Swift
public var isRoot: Bool { get }
-
isFile
Extension methodTrue if the file is a regular file (not a directory or a symbolic link).
Declaration
Swift
public var isFile: Bool { get }
-
isDirectory
Extension methodTrue if the file is a directory.
Declaration
Swift
public var isDirectory: Bool { get }
-
isSymbolicLink
Extension methodTrue if the file is a symbolic link.
Declaration
Swift
public var isSymbolicLink: Bool { get }
-
size
Extension methodThe size of the file (the same as
stat.size
).Declaration
Swift
public var size: Int { get }
-
fileExtension
Extension methodReturns the file extension, or an empty String if the file does not have an extension.
Declaration
Swift
public var fileExtension: String { get }
-
simpleNameWithoutExtension
Extension methodReturns the file name without its extension.
Declaration
Swift
public var simpleNameWithoutExtension: String { get }
-
openInputStream()
Extension methodOpens the input stream for the this file.
Declaration
Swift
public func openInputStream() throws -> FileInputStream
-
openOutputStream(overwrite:)
Extension methodOpens 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 methodReturns the path with symbolic link or alias resolved. THe returned path may be relative.
Declaration
Swift
public func readLink() throws -> String
-
isTheSameVolume(with:)
Extension methodReturns
true
if both files are located on the same volume.Declaration
Swift
public func isTheSameVolume(with other: VirtualFile) -> Bool
-
delete()
Extension methodDeletes the
file
.Declaration
Swift
public func delete() throws
-
copy(to:overwrite:progress:)
Extension methodCopies the
file
totarget
.Declaration
Swift
public func copy(to target: TargetFile, overwrite: Bool, progress: @escaping (Int) -> Bool = { _ in true }) throws
-
cacheSynchronously(progress:)
Extension methodCaches the file synchronously.
See also:
cache()
andcacheFiles()
.Declaration
Swift
public func cacheSynchronously(progress: @escaping (Int) -> Bool) throws -> TempFile
-
cache(_:onComplete:)
Extension methodCache 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).