IDesktopFileTransfers interface

Namespace Runic.Platform in Runic.Platform 0.23.0

public interface IDesktopFileTransfers

Copies and moves files and directories with progress, cancellation and a decision for each conflict, as a file manager does.

Remarks

A transfer puts each source into FileTransferRequest.DestinationDirectory under its own name. A file is written under a temporary name in the destination and renamed into place once complete, so cancellation or a failure never leaves a partial file under the real name. A move within one file system renames each source; a move to another file system copies it and then removes the source, only after its copy is complete.

A transfer keeps the content, the last write time and, on Linux and macOS, the permission bits of every file and directory, and on Windows the read-only, hidden and archive attributes. Symbolic links are copied as links and never followed. It does not keep owners, access control lists, extended attributes, alternate data streams, macOS resource forks and Finder information, hard links, which become separate files, or sparse regions. Other special files, such as named pipes and devices, are skipped.

Outcomes: a completed transfer is Success with a summary. The first error stops the transfer and is Failed: PlatformFailureCode.NotFound for a missing source or destination, PlatformFailureCode.PermissionDenied, PlatformFailureCode.Conflict for a conflict without a FileTransferRequest.ResolveConflict handler, PlatformFailureCode.UserDismissed when the handler answers FileConflictAction.Cancel, PlatformFailureCode.IOError, such as for a full disk, and PlatformFailureCode.Other for a native error no other code describes. Items transferred before an error or cancellation stay transferred; the item in progress is left as it was. Caller cancellation throws OperationCanceledException.

Methods

CopyAsync

ValueTask<PlatformResult<FileTransferSummary>> CopyAsync(FileTransferRequest request, CancellationToken cancellationToken = default)

Copies the request's sources into its destination directory.

Exceptions

ArgumentException

A source or the destination is not a fully qualified local path, there is no source, or the destination is a source or inside one.

MoveAsync

ValueTask<PlatformResult<FileTransferSummary>> MoveAsync(FileTransferRequest request, CancellationToken cancellationToken = default)

Moves the request's sources into its destination directory.

Exceptions

ArgumentException

A source or the destination is not a fully qualified local path, there is no source, or the destination is a source or inside one.