Change names of some enum members

This commit is contained in:
Alex Barney 2019-08-31 19:17:28 -05:00
parent dfff3b1ccf
commit f0ce5a9946
16 changed files with 30 additions and 30 deletions

View file

@ -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)

View file

@ -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;

View file

@ -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
}

View file

@ -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++;
}

View file

@ -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 <see cref="Write"/> is called on an offset past the end of the <see cref="IFile"/>,
/// the <see cref="OpenMode.Append"/> mode is set and the file supports expansion,
/// the <see cref="OpenMode.AllowAppend"/> mode is set and the file supports expansion,
/// the file will be expanded so that it is large enough to contain the written data.</remarks>
public interface IFile : IDisposable
{

View file

@ -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
}
/// <summary>

View file

@ -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;
}
}
}

View file

@ -25,7 +25,7 @@ namespace LibHac.Fs
public IEnumerable<DirectoryEntry> 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;
}

View file

@ -22,7 +22,7 @@ namespace LibHac.Fs
/// </summary>
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))
{

View file

@ -25,7 +25,7 @@ namespace LibHac.Fs.RomFs
FindPosition position = InitialPosition;
HierarchicalRomFileTable<RomFileInfo> 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<RomFileInfo> 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 _))
{

View file

@ -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 _))
{

View file

@ -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;

View file

@ -8,7 +8,7 @@ namespace LibHac.FsService.Creators
{
try
{
baseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directories);
baseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directory);
}
catch (HorizonResultException ex)
{

View file

@ -32,7 +32,7 @@ namespace LibHac.FsService
try
{
baseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directories);
baseFileSystem.OpenDirectory(path, OpenDirectoryMode.Directory);
}
catch (HorizonResultException ex)
{

View file

@ -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;

View file

@ -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)
{