コード例 #1
0
        /// <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));
            }
        }
コード例 #2
0
        public void DeleteDirectoryRecursively(string path)
        {
            string fullPath = GetFullPath(PathTools.Normalize(path));

            lock (Locker)
            {
                BaseFs.DeleteDirectoryRecursively(fullPath);
            }
        }
コード例 #3
0
        protected override Result DeleteDirectoryRecursivelyImpl(string path)
        {
            string fullPath = GetFullPath(PathTools.Normalize(path));

            lock (Locker)
            {
                return(BaseFs.DeleteDirectoryRecursively(fullPath));
            }
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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));
            }
        }
コード例 #7
0
        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));
        }
コード例 #8
0
        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));
            }
        }