From f0ce5a994692ee1ec1bc0eff3c9661f0b676e940 Mon Sep 17 00:00:00 2001 From: Alex Barney Date: Sat, 31 Aug 2019 19:17:28 -0500 Subject: [PATCH] Change names of some enum members --- src/LibHac/Fs/ConcatenationDirectory.cs | 4 ++-- src/LibHac/Fs/ConcatenationFileSystem.cs | 2 +- src/LibHac/Fs/FileBase.cs | 4 ++-- src/LibHac/Fs/FileSystemExtensions.cs | 6 +++--- src/LibHac/Fs/IFile.cs | 2 +- src/LibHac/Fs/IFileSystem.cs | 6 +++--- src/LibHac/Fs/LocalDirectory.cs | 4 ++-- src/LibHac/Fs/PartitionDirectory.cs | 4 ++-- src/LibHac/Fs/PartitionFileSystemBuilder.cs | 2 +- src/LibHac/Fs/RomFs/RomFsDirectory.cs | 8 ++++---- src/LibHac/Fs/Save/SaveDataDirectory.cs | 8 ++++---- src/LibHac/FsClient/FileSystemManagerUtils.cs | 2 +- .../FsService/Creators/SubDirectoryFileSystemCreator.cs | 2 +- src/LibHac/FsService/Util.cs | 2 +- src/hactoolnet/FsUtils.cs | 2 +- src/hactoolnet/Program.cs | 2 +- 16 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/LibHac/Fs/ConcatenationDirectory.cs b/src/LibHac/Fs/ConcatenationDirectory.cs index 770563f1..90718113 100644 --- a/src/LibHac/Fs/ConcatenationDirectory.cs +++ b/src/LibHac/Fs/ConcatenationDirectory.cs @@ -58,8 +58,8 @@ namespace LibHac.Fs private bool CanReturnEntry(DirectoryEntry entry, bool isSplit) { - return Mode.HasFlag(OpenDirectoryMode.Files) && (entry.Type == DirectoryEntryType.File || isSplit) || - Mode.HasFlag(OpenDirectoryMode.Directories) && entry.Type == DirectoryEntryType.Directory && !isSplit; + return Mode.HasFlag(OpenDirectoryMode.File) && (entry.Type == DirectoryEntryType.File || isSplit) || + Mode.HasFlag(OpenDirectoryMode.Directory) && entry.Type == DirectoryEntryType.Directory && !isSplit; } private bool IsConcatenationFile(DirectoryEntry entry) diff --git a/src/LibHac/Fs/ConcatenationFileSystem.cs b/src/LibHac/Fs/ConcatenationFileSystem.cs index fb242849..f9df0964 100644 --- a/src/LibHac/Fs/ConcatenationFileSystem.cs +++ b/src/LibHac/Fs/ConcatenationFileSystem.cs @@ -72,7 +72,7 @@ namespace LibHac.Fs if (BaseFileSystem.GetEntryType(PathTools.Combine(path, "00")) != DirectoryEntryType.File) return false; - if (BaseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directories).GetEntryCount() > 0) return false; + if (BaseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directory).GetEntryCount() > 0) return false; // Should be enough checks to avoid most false positives. Maybe return true; diff --git a/src/LibHac/Fs/FileBase.cs b/src/LibHac/Fs/FileBase.cs index aae12e8d..d84b30d4 100644 --- a/src/LibHac/Fs/FileBase.cs +++ b/src/LibHac/Fs/FileBase.cs @@ -46,7 +46,7 @@ namespace LibHac.Fs if (offset + size > fileSize) { - if ((Mode & OpenMode.Append) == 0) + if ((Mode & OpenMode.AllowAppend) == 0) { ThrowHelper.ThrowResult(ResultFs.AllowAppendRequiredForImplicitExtension); } @@ -87,7 +87,7 @@ namespace LibHac.Fs { Read = 1, Write = 2, - Append = 4, + AllowAppend = 4, ReadWrite = Read | Write } diff --git a/src/LibHac/Fs/FileSystemExtensions.cs b/src/LibHac/Fs/FileSystemExtensions.cs index cc88706b..8669d230 100644 --- a/src/LibHac/Fs/FileSystemExtensions.cs +++ b/src/LibHac/Fs/FileSystemExtensions.cs @@ -31,7 +31,7 @@ namespace LibHac.Fs destFs.CreateOrOverwriteFile(subDstPath, entry.Size, options); using (IFile srcFile = sourceFs.OpenFile(subSrcPath, OpenMode.Read)) - using (IFile dstFile = destFs.OpenFile(subDstPath, OpenMode.Write | OpenMode.Append)) + using (IFile dstFile = destFs.OpenFile(subDstPath, OpenMode.Write | OpenMode.AllowAppend)) { logger?.LogMessage(subSrcPath); srcFile.CopyTo(dstFile, logger); @@ -142,8 +142,8 @@ namespace LibHac.Fs foreach (DirectoryEntry entry in directory.EnumerateEntries()) { - if (entry.Type == DirectoryEntryType.Directory && (mode & OpenDirectoryMode.Directories) != 0 || - entry.Type == DirectoryEntryType.File && (mode & OpenDirectoryMode.Files) != 0) + if (entry.Type == DirectoryEntryType.Directory && (mode & OpenDirectoryMode.Directory) != 0 || + entry.Type == DirectoryEntryType.File && (mode & OpenDirectoryMode.File) != 0) { count++; } diff --git a/src/LibHac/Fs/IFile.cs b/src/LibHac/Fs/IFile.cs index 22bef0bf..ad4136f9 100644 --- a/src/LibHac/Fs/IFile.cs +++ b/src/LibHac/Fs/IFile.cs @@ -14,7 +14,7 @@ namespace LibHac.Fs /// or write as many bytes as it can and return that number of bytes to the caller. /// /// - If is called on an offset past the end of the , - /// the mode is set and the file supports expansion, + /// the mode is set and the file supports expansion, /// the file will be expanded so that it is large enough to contain the written data. public interface IFile : IDisposable { diff --git a/src/LibHac/Fs/IFileSystem.cs b/src/LibHac/Fs/IFileSystem.cs index 827d2f15..dc62fb24 100644 --- a/src/LibHac/Fs/IFileSystem.cs +++ b/src/LibHac/Fs/IFileSystem.cs @@ -204,9 +204,9 @@ namespace LibHac.Fs [Flags] public enum OpenDirectoryMode { - Directories = 1, - Files = 2, - All = Directories | Files + Directory = 1, + File = 2, + All = Directory | File } /// diff --git a/src/LibHac/Fs/LocalDirectory.cs b/src/LibHac/Fs/LocalDirectory.cs index be1069b7..3086be3b 100644 --- a/src/LibHac/Fs/LocalDirectory.cs +++ b/src/LibHac/Fs/LocalDirectory.cs @@ -73,8 +73,8 @@ namespace LibHac.Fs [MethodImpl(MethodImplOptions.AggressiveInlining)] private static bool CanReturnEntry(bool isDir, OpenDirectoryMode mode) { - return isDir && (mode & OpenDirectoryMode.Directories) != 0 || - !isDir && (mode & OpenDirectoryMode.Files) != 0; + return isDir && (mode & OpenDirectoryMode.Directory) != 0 || + !isDir && (mode & OpenDirectoryMode.File) != 0; } } } diff --git a/src/LibHac/Fs/PartitionDirectory.cs b/src/LibHac/Fs/PartitionDirectory.cs index 99dc6102..dc6e4db1 100644 --- a/src/LibHac/Fs/PartitionDirectory.cs +++ b/src/LibHac/Fs/PartitionDirectory.cs @@ -25,7 +25,7 @@ namespace LibHac.Fs public IEnumerable Read() { - if (Mode.HasFlag(OpenDirectoryMode.Files)) + if (Mode.HasFlag(OpenDirectoryMode.File)) { foreach (PartitionFileEntry entry in ParentFileSystem.Files) { @@ -38,7 +38,7 @@ namespace LibHac.Fs { int count = 0; - if (Mode.HasFlag(OpenDirectoryMode.Files)) + if (Mode.HasFlag(OpenDirectoryMode.File)) { count += ParentFileSystem.Files.Length; } diff --git a/src/LibHac/Fs/PartitionFileSystemBuilder.cs b/src/LibHac/Fs/PartitionFileSystemBuilder.cs index 62fdd00b..5eed802a 100644 --- a/src/LibHac/Fs/PartitionFileSystemBuilder.cs +++ b/src/LibHac/Fs/PartitionFileSystemBuilder.cs @@ -22,7 +22,7 @@ namespace LibHac.Fs /// public PartitionFileSystemBuilder(IFileSystem input) { - IDirectory rootDir = input.OpenDirectory("/", OpenDirectoryMode.Files); + IDirectory rootDir = input.OpenDirectory("/", OpenDirectoryMode.File); foreach (DirectoryEntry file in rootDir.Read().OrderBy(x => x.FullPath, StringComparer.Ordinal)) { diff --git a/src/LibHac/Fs/RomFs/RomFsDirectory.cs b/src/LibHac/Fs/RomFs/RomFsDirectory.cs index 982ae423..3b8cb119 100644 --- a/src/LibHac/Fs/RomFs/RomFsDirectory.cs +++ b/src/LibHac/Fs/RomFs/RomFsDirectory.cs @@ -25,7 +25,7 @@ namespace LibHac.Fs.RomFs FindPosition position = InitialPosition; HierarchicalRomFileTable tab = ParentFileSystem.FileTable; - if (Mode.HasFlag(OpenDirectoryMode.Directories)) + if (Mode.HasFlag(OpenDirectoryMode.Directory)) { while (tab.FindNextDirectory(ref position, out string name)) { @@ -33,7 +33,7 @@ namespace LibHac.Fs.RomFs } } - if (Mode.HasFlag(OpenDirectoryMode.Files)) + if (Mode.HasFlag(OpenDirectoryMode.File)) { while (tab.FindNextFile(ref position, out RomFileInfo info, out string name)) { @@ -49,7 +49,7 @@ namespace LibHac.Fs.RomFs FindPosition position = InitialPosition; HierarchicalRomFileTable tab = ParentFileSystem.FileTable; - if (Mode.HasFlag(OpenDirectoryMode.Directories)) + if (Mode.HasFlag(OpenDirectoryMode.Directory)) { while (tab.FindNextDirectory(ref position, out string _)) { @@ -57,7 +57,7 @@ namespace LibHac.Fs.RomFs } } - if (Mode.HasFlag(OpenDirectoryMode.Files)) + if (Mode.HasFlag(OpenDirectoryMode.File)) { while (tab.FindNextFile(ref position, out RomFileInfo _, out string _)) { diff --git a/src/LibHac/Fs/Save/SaveDataDirectory.cs b/src/LibHac/Fs/Save/SaveDataDirectory.cs index 84a26b96..b2fe7fd3 100644 --- a/src/LibHac/Fs/Save/SaveDataDirectory.cs +++ b/src/LibHac/Fs/Save/SaveDataDirectory.cs @@ -25,7 +25,7 @@ namespace LibHac.Fs.Save SaveFindPosition position = InitialPosition; HierarchicalSaveFileTable tab = ParentFileSystem.FileTable; - if (Mode.HasFlag(OpenDirectoryMode.Directories)) + if (Mode.HasFlag(OpenDirectoryMode.Directory)) { while (tab.FindNextDirectory(ref position, out string name)) { @@ -33,7 +33,7 @@ namespace LibHac.Fs.Save } } - if (Mode.HasFlag(OpenDirectoryMode.Files)) + if (Mode.HasFlag(OpenDirectoryMode.File)) { while (tab.FindNextFile(ref position, out SaveFileInfo info, out string name)) { @@ -49,7 +49,7 @@ namespace LibHac.Fs.Save SaveFindPosition position = InitialPosition; HierarchicalSaveFileTable tab = ParentFileSystem.FileTable; - if (Mode.HasFlag(OpenDirectoryMode.Directories)) + if (Mode.HasFlag(OpenDirectoryMode.Directory)) { while (tab.FindNextDirectory(ref position, out string _)) { @@ -57,7 +57,7 @@ namespace LibHac.Fs.Save } } - if (Mode.HasFlag(OpenDirectoryMode.Files)) + if (Mode.HasFlag(OpenDirectoryMode.File)) { while (tab.FindNextFile(ref position, out SaveFileInfo _, out string _)) { diff --git a/src/LibHac/FsClient/FileSystemManagerUtils.cs b/src/LibHac/FsClient/FileSystemManagerUtils.cs index 5cdd0807..85a5b7fe 100644 --- a/src/LibHac/FsClient/FileSystemManagerUtils.cs +++ b/src/LibHac/FsClient/FileSystemManagerUtils.cs @@ -39,7 +39,7 @@ namespace LibHac.FsClient public static void CopyFile(this FileSystemManager fs, string sourcePath, string destPath, IProgressReport logger = null) { using (FileHandle sourceHandle = fs.OpenFile(sourcePath, OpenMode.Read)) - using (FileHandle destHandle = fs.OpenFile(destPath, OpenMode.Write | OpenMode.Append)) + using (FileHandle destHandle = fs.OpenFile(destPath, OpenMode.Write | OpenMode.AllowAppend)) { const int maxBufferSize = 0x10000; diff --git a/src/LibHac/FsService/Creators/SubDirectoryFileSystemCreator.cs b/src/LibHac/FsService/Creators/SubDirectoryFileSystemCreator.cs index 526ffb4e..5f19cdc4 100644 --- a/src/LibHac/FsService/Creators/SubDirectoryFileSystemCreator.cs +++ b/src/LibHac/FsService/Creators/SubDirectoryFileSystemCreator.cs @@ -8,7 +8,7 @@ namespace LibHac.FsService.Creators { try { - baseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directories); + baseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directory); } catch (HorizonResultException ex) { diff --git a/src/LibHac/FsService/Util.cs b/src/LibHac/FsService/Util.cs index 3b151c1e..0a0b8a62 100644 --- a/src/LibHac/FsService/Util.cs +++ b/src/LibHac/FsService/Util.cs @@ -32,7 +32,7 @@ namespace LibHac.FsService try { - baseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directories); + baseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directory); } catch (HorizonResultException ex) { diff --git a/src/hactoolnet/FsUtils.cs b/src/hactoolnet/FsUtils.cs index eb752b27..4aba3927 100644 --- a/src/hactoolnet/FsUtils.cs +++ b/src/hactoolnet/FsUtils.cs @@ -67,7 +67,7 @@ namespace hactoolnet public static void CopyFileWithProgress(FileSystemManager fs, string sourcePath, string destPath, IProgressReport logger = null) { using (FileHandle sourceHandle = fs.OpenFile(sourcePath, OpenMode.Read)) - using (FileHandle destHandle = fs.OpenFile(destPath, OpenMode.Write | OpenMode.Append)) + using (FileHandle destHandle = fs.OpenFile(destPath, OpenMode.Write | OpenMode.AllowAppend)) { const int maxBufferSize = 1024 * 1024; diff --git a/src/hactoolnet/Program.cs b/src/hactoolnet/Program.cs index 9f39a649..a1222357 100644 --- a/src/hactoolnet/Program.cs +++ b/src/hactoolnet/Program.cs @@ -57,7 +57,7 @@ namespace hactoolnet using (var logger = new ProgressBar()) { ctx.Logger = logger; - ctx.Horizon = new Horizon(new TimeSpanTimer()); + ctx.Horizon = new Horizon(new StopWatchTimeSpanGenerator()); if (ctx.Options.AccessLog != null) {