NanoByte.Common
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Properties | List of all members
NanoByte.Common.Storage.CopyDirectory Class Reference

Copies the content of a directory to a new location preserving the original file modification times and relative Unix symlinks. More...

Inheritance diagram for NanoByte.Common.Storage.CopyDirectory:
NanoByte.Common.Tasks.TaskBase NanoByte.Common.Tasks.ITask NanoByte.Common.Storage.MoveDirectory

Public Member Functions

 CopyDirectory ([Localizable(false)] string sourcePath, [Localizable(false)] string destinationPath, bool preserveDirectoryTimestamps=true, bool overwrite=false)
 Creates a new directory copy task. More...
 
- Public Member Functions inherited from NanoByte.Common.Tasks.TaskBase
void Run (CancellationToken cancellationToken=default, ICredentialProvider? credentialProvider=null, IProgress< TaskSnapshot >? progress=null)
 Runs the task and blocks until it is complete.
 

Public Attributes

override string Name => Resources.CopyFiles
 
- Public Attributes inherited from NanoByte.Common.Tasks.TaskBase
virtual bool CanCancel => true
 

Protected Member Functions

override void Execute ()
 The actual code to be executed.
 
virtual void CopyFile (FileInfo sourceFile, FileInfo destinationFile)
 Copies a single file from one location to another. Can be overridden to modify the copying behavior. More...
 
virtual void CreateSymlink ([Localizable(false)] string linkPath, [Localizable(false)] string linkTarget)
 Creates a Unix symbolic link. Can be overridden to modify the symlinking behavior. More...
 

Protected Attributes

override bool UnitsByte => true
 
- Protected Attributes inherited from NanoByte.Common.Tasks.TaskBase
CancellationToken CancellationToken
 Signaled when the user wishes to cancel the task execution. More...
 
ICredentialProviderCredentialProvider
 Used to retrieve credentials for specific Uris on demand; can be null. More...
 

Properties

string SourcePath [get]
 The path of source directory. Must exist! More...
 
string DestinationPath [get]
 The path of the target directory. May exist. Must be empty if Overwrite is false. More...
 
bool PreserveDirectoryTimestamps [get]
 true to preserve the modification times for directories as well; false to preserve only the file modification times. More...
 
bool Overwrite [get]
 Overwrite existing files and directories at the DestinationPath. This will even replace read-only files! More...
 
- Properties inherited from NanoByte.Common.Tasks.TaskBase
abstract string Name [get]
 
object? Tag [get, set]
 
TaskState State [get, protected set]
 The current State of the task. More...
 
abstract bool UnitsByte [get]
 true if UnitsProcessed and UnitsTotal are measured in bytes; false if they are measured in generic units. More...
 
long UnitsProcessed [get, set]
 The number of units that have been processed so far. More...
 
long UnitsTotal [get, set]
 The total number of units that are to be processed; -1 for unknown. More...
 
- Properties inherited from NanoByte.Common.Tasks.ITask
string Name [get]
 A name describing the task in human-readable form. More...
 
object? Tag [get, set]
 An object used to associate the task with a specific process; can be null. More...
 
bool CanCancel [get]
 Indicates whether this task can be canceled once it has been started. More...
 

Detailed Description

Copies the content of a directory to a new location preserving the original file modification times and relative Unix symlinks.

Constructor & Destructor Documentation

◆ CopyDirectory()

NanoByte.Common.Storage.CopyDirectory.CopyDirectory ( [Localizable(false)] string  sourcePath,
[Localizable(false)] string  destinationPath,
bool  preserveDirectoryTimestamps = true,
bool  overwrite = false 
)
inline

Creates a new directory copy task.

Parameters
sourcePathThe path of source directory. Must exist!
destinationPathThe path of the target directory. May exist. Must be empty if overwrite is false.
preserveDirectoryTimestampstrue to preserve the modification times for directories as well; false to preserve only the file modification times.
overwriteOverwrite existing files and directories at the destinationPath . This will even replace read-only files!

Member Function Documentation

◆ CopyFile()

virtual void NanoByte.Common.Storage.CopyDirectory.CopyFile ( FileInfo  sourceFile,
FileInfo  destinationFile 
)
inlineprotectedvirtual

Copies a single file from one location to another. Can be overridden to modify the copying behavior.

Exceptions
IOExceptionA problem occurred while copying the file.
UnauthorizedAccessExceptionRead access to the sourceFile or write access to the destinationFile is not permitted.

Reimplemented in NanoByte.Common.Storage.MoveDirectory.

◆ CreateSymlink()

virtual void NanoByte.Common.Storage.CopyDirectory.CreateSymlink ( [Localizable(false)] string  linkPath,
[Localizable(false)] string  linkTarget 
)
inlineprotectedvirtual

Creates a Unix symbolic link. Can be overridden to modify the symlinking behavior.

Parameters
linkPathThe path of the link to create.
linkTargetThe path of the existing file or directory to point to (relative to linkPath ).
Exceptions
InvalidOperationExceptionThe underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).
IOExceptionThe underlying Unix subsystem failed to process the request (e.g. because of insufficient rights).

Property Documentation

◆ DestinationPath

string NanoByte.Common.Storage.CopyDirectory.DestinationPath
get

The path of the target directory. May exist. Must be empty if Overwrite is false.

◆ Overwrite

bool NanoByte.Common.Storage.CopyDirectory.Overwrite
get

Overwrite existing files and directories at the DestinationPath. This will even replace read-only files!

◆ PreserveDirectoryTimestamps

bool NanoByte.Common.Storage.CopyDirectory.PreserveDirectoryTimestamps
get

true to preserve the modification times for directories as well; false to preserve only the file modification times.

◆ SourcePath

string NanoByte.Common.Storage.CopyDirectory.SourcePath
get

The path of source directory. Must exist!


The documentation for this class was generated from the following file: