Other Functions

The following functions are available globally.

  • Copy source file to target with generic file streams.

    - Parameter overwrite: `true` if the target file may be overwritten.
    If false, an exception will occur if the target file already exists.
    
    - Parameter mode: the file mode of the newly created file. Should contain either `S_IFLNK` or `S_IFREG` flag.
    
    - Parameter bufferSize: the intermediate buffer size in bytes.
    
    - Parameter progress: the progress callback.
    The passed `Int` is a number of the bytes copied.
    Return `false` if you want to stop copying, `true` otherwise.
    

    Declaration

    Swift

    public func copyFileUsingStreams(
            source: VirtualFile,
            target: TargetFile,
            overwrite: Bool,
            mode: mode_t,
            bufferSize: Int = DEFAULT_BUFFER_SIZE,
            progress: (Int) -> Bool = { _ in true }
    ) throws

    Parameters

    overwrite
    mode
    bufferSize
    progress
  • Copy input stream to output.

    - Parameter bufferSize: the intermediate buffer size in bytes.
    
    - Parameter progress: the progress callback.
    The passed `Int` is a number of the bytes copied.
    Return `false` if you want to stop copying, `true` otherwise.
    

    Declaration

    Swift

    public func copyStreams(
            input: FileInputStream,
            output: FileOutputStream,
            bufferSize: Int = DEFAULT_BUFFER_SIZE,
            progress: (Int) -> Bool = { _ in true }
    ) throws

    Parameters

    bufferSize
    progress
  • Cache the files asynchronously with the progress window.

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

    Declaration

    Swift

    public func cacheFiles(
            _ files: [VirtualFile],
            _ 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).