/// <summary> /// Creates the destination directory if needed and copies the source directory to it. /// </summary> /// <param name="destPath">The path of the destination directory.</param> /// <param name="sourcePath">The path of the source directory.</param> /// <returns>The <see cref="Result"/> of the operation.</returns> private Result SynchronizeDirectory(U8Span destPath, U8Span sourcePath) { // Delete destination dir and recreate it. Result rc = BaseFs.DeleteDirectoryRecursively(destPath); // Nintendo returns error unconditionally because SynchronizeDirectory is always called in situations // where a PathNotFound error would mean the save directory was in an invalid state. // We'll ignore PathNotFound errors to be more user-friendly to users who might accidentally // put the save directory in an invalid state. if (rc.IsFailure() && !ResultFs.PathNotFound.Includes(rc)) { return(rc); } rc = BaseFs.CreateDirectory(destPath); if (rc.IsFailure()) { return(rc); } // Get a work buffer to work with. using (var buffer = new RentedArray <byte>(IdealWorkBufferSize)) { return(Utility.CopyDirectoryRecursively(BaseFs, destPath, sourcePath, buffer.Span)); } }
public void DeleteDirectoryRecursively(string path) { string fullPath = GetFullPath(PathTools.Normalize(path)); lock (Locker) { BaseFs.DeleteDirectoryRecursively(fullPath); } }
protected override Result DeleteDirectoryRecursivelyImpl(string path) { string fullPath = GetFullPath(PathTools.Normalize(path)); lock (Locker) { return(BaseFs.DeleteDirectoryRecursively(fullPath)); } }
public void Commit() { if (OpenWritableFileCount > 0) { throw new InvalidOperationException("All files must be closed before commiting save data."); } SynchronizeDirectory(SyncDir, WorkingDir); BaseFs.DeleteDirectoryRecursively(CommittedDir); BaseFs.RenameDirectory(SyncDir, CommittedDir); }
private void SynchronizeDirectory(string dest, string src) { if (BaseFs.DirectoryExists(dest)) { BaseFs.DeleteDirectoryRecursively(dest); } BaseFs.CreateDirectory(dest); IDirectory sourceDir = BaseFs.OpenDirectory(src, OpenDirectoryMode.All); IDirectory destDir = BaseFs.OpenDirectory(dest, OpenDirectoryMode.All); sourceDir.CopyDirectory(destDir); }
protected override Result DoDeleteDirectoryRecursively(U8Span path) { Unsafe.SkipInit(out FsPath fullPath); Result rc = ResolveFullPath(fullPath.Str, path); if (rc.IsFailure()) { return(rc); } lock (Locker) { return(BaseFs.DeleteDirectoryRecursively(fullPath)); } }
private Result SynchronizeDirectory(string dest, string src) { Result rc = BaseFs.DeleteDirectoryRecursively(dest); if (rc.IsFailure() && rc != ResultFs.PathNotFound) { return(rc); } rc = BaseFs.CreateDirectory(dest); if (rc.IsFailure()) { return(rc); } return(BaseFs.CopyDirectory(BaseFs, src, dest)); }
protected override Result DoDeleteDirectoryRecursively(U8Span path) { FsPath fullPath; unsafe { _ = &fullPath; } // workaround for CS0165 Result rc = ResolveFullPath(fullPath.Str, path); if (rc.IsFailure()) { return(rc); } lock (Locker) { return(BaseFs.DeleteDirectoryRecursively(fullPath)); } }