Move new path code to the proper namespace

This commit is contained in:
Alex Barney 2021-07-13 01:14:25 -07:00
parent a7f5c7c041
commit 8a5ecb18f8
20 changed files with 57 additions and 48 deletions

View file

@ -6,7 +6,8 @@ using LibHac.Diag;
using LibHac.Util;
using static LibHac.Fs.StringTraits;
namespace LibHac.Fs.Common
// ReSharper disable once CheckNamespace
namespace LibHac.Fs
{
public struct PathFlags
{

View file

@ -8,7 +8,8 @@ using LibHac.FsSystem;
using LibHac.Util;
using static LibHac.Fs.StringTraits;
namespace LibHac.Fs.Common
// ReSharper disable once CheckNamespace
namespace LibHac.Fs
{
public static class PathFormatter
{

View file

@ -2,10 +2,11 @@
using LibHac.Common;
using LibHac.Diag;
using LibHac.FsSystem;
using static LibHac.Fs.Common.PathUtility12;
using static LibHac.Fs.PathUtility12;
using static LibHac.Fs.StringTraits;
namespace LibHac.Fs.Common
// ReSharper disable once CheckNamespace
namespace LibHac.Fs
{
public static class PathNormalizer12
{

View file

@ -1,12 +1,12 @@
using System;
using System.Runtime.CompilerServices;
using LibHac.Common;
using LibHac.Diag;
using LibHac.FsSrv.Sf;
using LibHac.Util;
using static LibHac.Fs.StringTraits;
namespace LibHac.Fs.Common
// ReSharper disable once CheckNamespace
namespace LibHac.Fs
{
public static class PathUtility12
{

View file

@ -4,7 +4,8 @@ using LibHac.Diag;
using LibHac.Util;
using static LibHac.Util.CharacterEncoding;
namespace LibHac.Fs.Common
// ReSharper disable once CheckNamespace
namespace LibHac.Fs
{
public static class WindowsPath12
{

View file

@ -2,11 +2,11 @@
using System.Runtime.CompilerServices;
using LibHac.Common;
using LibHac.Fs.Fsa;
using LibHac.FsSrv.Sf;
using LibHac.Util;
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
using IFileSf = LibHac.FsSrv.Sf.IFile;
using IDirectorySf = LibHac.FsSrv.Sf.IDirectory;
using PathSf = LibHac.FsSrv.Sf.Path;
namespace LibHac.Fs.Impl
{
@ -14,7 +14,7 @@ namespace LibHac.Fs.Impl
/// An adapter for using an <see cref="IFileSystemSf"/> service object as an <see cref="Fsa.IFileSystem"/>. Used
/// when receiving a Horizon IPC file system object so it can be used as an <see cref="Fsa.IFileSystem"/> locally.
/// </summary>
internal class FileSystemServiceObjectAdapter : Fsa.IFileSystem, IMultiCommitTarget
internal class FileSystemServiceObjectAdapter : IFileSystem, IMultiCommitTarget
{
private ReferenceCountedDisposable<IFileSystemSf> BaseFs { get; }
@ -25,7 +25,7 @@ namespace LibHac.Fs.Impl
protected override Result DoCreateFile(U8Span path, long size, CreateFileOptions option)
{
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.CreateFile(in sfPath, size, (int)option);
@ -33,7 +33,7 @@ namespace LibHac.Fs.Impl
protected override Result DoDeleteFile(U8Span path)
{
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.DeleteFile(in sfPath);
@ -41,7 +41,7 @@ namespace LibHac.Fs.Impl
protected override Result DoCreateDirectory(U8Span path)
{
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.DeleteFile(in sfPath);
@ -49,7 +49,7 @@ namespace LibHac.Fs.Impl
protected override Result DoDeleteDirectory(U8Span path)
{
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.DeleteDirectory(in sfPath);
@ -57,7 +57,7 @@ namespace LibHac.Fs.Impl
protected override Result DoDeleteDirectoryRecursively(U8Span path)
{
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.DeleteDirectoryRecursively(in sfPath);
@ -65,7 +65,7 @@ namespace LibHac.Fs.Impl
protected override Result DoCleanDirectoryRecursively(U8Span path)
{
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.CleanDirectoryRecursively(in sfPath);
@ -73,10 +73,10 @@ namespace LibHac.Fs.Impl
protected override Result DoRenameFile(U8Span oldPath, U8Span newPath)
{
Result rc = GetPathForServiceObject(out Path oldSfPath, oldPath);
Result rc = GetPathForServiceObject(out PathSf oldSfPath, oldPath);
if (rc.IsFailure()) return rc;
rc = GetPathForServiceObject(out Path newSfPath, newPath);
rc = GetPathForServiceObject(out PathSf newSfPath, newPath);
if (rc.IsFailure()) return rc;
return BaseFs.Target.RenameFile(in oldSfPath, in newSfPath);
@ -84,10 +84,10 @@ namespace LibHac.Fs.Impl
protected override Result DoRenameDirectory(U8Span oldPath, U8Span newPath)
{
Result rc = GetPathForServiceObject(out Path oldSfPath, oldPath);
Result rc = GetPathForServiceObject(out PathSf oldSfPath, oldPath);
if (rc.IsFailure()) return rc;
rc = GetPathForServiceObject(out Path newSfPath, newPath);
rc = GetPathForServiceObject(out PathSf newSfPath, newPath);
if (rc.IsFailure()) return rc;
return BaseFs.Target.RenameDirectory(in oldSfPath, in newSfPath);
@ -97,7 +97,7 @@ namespace LibHac.Fs.Impl
{
UnsafeHelpers.SkipParamInit(out entryType);
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
ref uint sfEntryType = ref Unsafe.As<DirectoryEntryType, uint>(ref entryType);
@ -109,7 +109,7 @@ namespace LibHac.Fs.Impl
{
UnsafeHelpers.SkipParamInit(out freeSpace);
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.GetFreeSpaceSize(out freeSpace, in sfPath);
@ -119,17 +119,17 @@ namespace LibHac.Fs.Impl
{
UnsafeHelpers.SkipParamInit(out totalSpace);
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.GetTotalSpaceSize(out totalSpace, in sfPath);
}
protected override Result DoOpenFile(out Fsa.IFile file, U8Span path, OpenMode mode)
protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
{
UnsafeHelpers.SkipParamInit(out file);
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
ReferenceCountedDisposable<IFileSf> sfFile = null;
@ -147,11 +147,11 @@ namespace LibHac.Fs.Impl
}
}
protected override Result DoOpenDirectory(out Fsa.IDirectory directory, U8Span path, OpenDirectoryMode mode)
protected override Result DoOpenDirectory(out IDirectory directory, U8Span path, OpenDirectoryMode mode)
{
UnsafeHelpers.SkipParamInit(out directory);
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
ReferenceCountedDisposable<IDirectorySf> sfDir = null;
@ -178,7 +178,7 @@ namespace LibHac.Fs.Impl
{
UnsafeHelpers.SkipParamInit(out timeStamp);
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.GetFileTimeStampRaw(out timeStamp, in sfPath);
@ -187,7 +187,7 @@ namespace LibHac.Fs.Impl
protected override Result DoQueryEntry(Span<byte> outBuffer, ReadOnlySpan<byte> inBuffer, QueryId queryId,
U8Span path)
{
Result rc = GetPathForServiceObject(out Path sfPath, path);
Result rc = GetPathForServiceObject(out PathSf sfPath, path);
if (rc.IsFailure()) return rc;
return BaseFs.Target.QueryEntry(outBuffer, inBuffer, (int)queryId, in sfPath);
@ -208,7 +208,7 @@ namespace LibHac.Fs.Impl
base.Dispose(disposing);
}
private Result GetPathForServiceObject(out Path sfPath, U8Span path)
private Result GetPathForServiceObject(out PathSf sfPath, U8Span path)
{
// This is the function used to create Sf.Path structs. Get an unsafe byte span for init only.
UnsafeHelpers.SkipParamInit(out sfPath);
@ -216,7 +216,7 @@ namespace LibHac.Fs.Impl
// Copy and null terminate
StringUtils.Copy(outPath, path);
outPath[Unsafe.SizeOf<Path>() - 1] = StringTraits.NullTerminator;
outPath[Unsafe.SizeOf<PathSf>() - 1] = StringTraits.NullTerminator;
// Replace directory separators
PathUtility.Replace(outPath, StringTraits.AltDirectorySeparator, StringTraits.DirectorySeparator);

View file

@ -3,12 +3,12 @@ using System.Runtime.CompilerServices;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Fsa;
using LibHac.FsSrv.Sf;
using LibHac.Util;
using IFileSystem = LibHac.Fs.Fsa.IFileSystem;
using IFileSystemSf = LibHac.FsSrv.Sf.IFileSystem;
using IFileSf = LibHac.FsSrv.Sf.IFile;
using IDirectorySf = LibHac.FsSrv.Sf.IDirectory;
using Path = LibHac.FsSrv.Sf.Path;
namespace LibHac.FsSrv.Impl
{
@ -182,7 +182,7 @@ namespace LibHac.FsSrv.Impl
if (normalizer.Result.IsFailure()) return normalizer.Result;
Result rc = Result.Success;
Fs.Fsa.IFile fileInterface = null;
IFile fileInterface = null;
for (int tryNum = 0; tryNum < maxTryCount; tryNum++)
{
@ -211,7 +211,7 @@ namespace LibHac.FsSrv.Impl
if (normalizer.Result.IsFailure()) return normalizer.Result;
Result rc = Result.Success;
Fs.Fsa.IDirectory dirInterface = null;
IDirectory dirInterface = null;
for (int tryNum = 0; tryNum < maxTryCount; tryNum++)
{

View file

@ -5,6 +5,7 @@ using LibHac.Fs;
using LibHac.Lr;
using LibHac.Ncm;
using LibHac.Os;
using Path = LibHac.Lr.Path;
namespace LibHac.FsSrv.Impl
{

View file

@ -8,13 +8,13 @@ using LibHac.FsSrv.FsCreator;
using LibHac.FsSrv.Impl;
using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.Lr;
using LibHac.Ncm;
using LibHac.Os;
using LibHac.Spl;
using LibHac.Util;
using RightsId = LibHac.Fs.RightsId;
using Utility = LibHac.FsSrv.Impl.Utility;
using PathLr = LibHac.Lr.Path;
namespace LibHac.FsSrv
{
@ -828,7 +828,7 @@ namespace LibHac.FsSrv
return Result.Success;
}
public Result ResolveProgramPath(out Path path, ProgramId programId, StorageId storageId)
public Result ResolveProgramPath(out PathLr path, ProgramId programId, StorageId storageId)
{
Result rc = _locationResolverSet.ResolveProgramPath(out path, programId.Value, storageId);
if (rc.IsSuccess())
@ -843,18 +843,18 @@ namespace LibHac.FsSrv
return ResultFs.TargetNotFound.Log();
}
public Result ResolveRomPath(out Path path, ulong id, StorageId storageId)
public Result ResolveRomPath(out PathLr path, ulong id, StorageId storageId)
{
return _locationResolverSet.ResolveRomPath(out path, id, storageId);
}
public Result ResolveApplicationHtmlDocumentPath(out Path path, Ncm.ApplicationId applicationId,
public Result ResolveApplicationHtmlDocumentPath(out PathLr path, Ncm.ApplicationId applicationId,
StorageId storageId)
{
return _locationResolverSet.ResolveApplicationHtmlDocumentPath(out path, applicationId, storageId);
}
public Result ResolveRegisteredHtmlDocumentPath(out Path path, ulong id)
public Result ResolveRegisteredHtmlDocumentPath(out PathLr path, ulong id)
{
return _locationResolverSet.ResolveRegisteredHtmlDocumentPath(out path, id);
}

View file

@ -56,7 +56,7 @@ namespace LibHac.FsSystem
/// <param name="rootPath">The path that will be the root of the <see cref="LocalFileSystem"/>.</param>
public LocalFileSystem(string rootPath)
{
_rootPath = Path.GetFullPath(rootPath);
_rootPath = System.IO.Path.GetFullPath(rootPath);
if (!Directory.Exists(_rootPath))
{
@ -98,7 +98,7 @@ namespace LibHac.FsSystem
try
{
_rootPath = Path.GetFullPath(rootPath);
_rootPath = System.IO.Path.GetFullPath(rootPath);
}
catch (PathTooLongException)
{

View file

@ -126,7 +126,7 @@ namespace LibHac
foreach (DirectoryEntryEx fileEntry in SaveFs.EnumerateEntries().Where(x => x.Type == DirectoryEntryType.File))
{
SaveDataFileSystem save = null;
string saveName = Path.GetFileNameWithoutExtension(fileEntry.Name);
string saveName = System.IO.Path.GetFileNameWithoutExtension(fileEntry.Name);
try
{
@ -251,7 +251,7 @@ namespace LibHac
{
if (nca.Nca.Header.ContentType != NcaContentType.Meta || !name.EndsWith(".cnmt.nca"))
{
return Path.GetFileNameWithoutExtension(name);
return System.IO.Path.GetFileNameWithoutExtension(name);
}
return name.Substring(0, name.Length - ".cnmt.nca".Length);

View file

@ -52,7 +52,7 @@ namespace hactoolnet
kipReader.Initialize(kipStorage).ThrowIfFailure();
kipStorage.WriteAllBytes(Path.Combine(outDir, $"{kipReader.Name.ToString()}.kip1"));
kipStorage.WriteAllBytes(System.IO.Path.Combine(outDir, $"{kipReader.Name.ToString()}.kip1"));
}
}
}

View file

@ -7,6 +7,7 @@ using LibHac.Common;
using LibHac.Fs;
using LibHac.FsSystem;
using static hactoolnet.Print;
using Path = System.IO.Path;
namespace hactoolnet
{

View file

@ -12,6 +12,7 @@ using LibHac.Fs.Impl;
using LibHac.FsSystem;
using LibHac.FsSystem.Save;
using static hactoolnet.Print;
using Path = System.IO.Path;
namespace hactoolnet
{

View file

@ -11,6 +11,7 @@ using LibHac.FsSystem;
using LibHac.FsSystem.NcaUtils;
using LibHac.FsSystem.Save;
using LibHac.Ns;
using Path = System.IO.Path;
namespace hactoolnet
{

View file

@ -56,7 +56,7 @@ namespace hactoolnet
foreach (PartitionFileEntry sub in root.Files)
{
var subPfs = new PartitionFileSystem(root.OpenFile(sub, OpenMode.Read).AsStorage());
string subDir = Path.Combine(ctx.Options.OutDir, sub.Name);
string subDir = System.IO.Path.Combine(ctx.Options.OutDir, sub.Name);
subPfs.Extract(subDir, ctx.Logger);
}

View file

@ -6,6 +6,7 @@ using LibHac.Common.Keys;
using LibHac.Diag;
using LibHac.Fs;
using LibHac.Util;
using Path = System.IO.Path;
namespace hactoolnet
{

View file

@ -3,7 +3,6 @@
using System;
using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Common;
using LibHac.Util;
using Xunit;

View file

@ -2,7 +2,6 @@
using LibHac.Common;
using LibHac.Fs;
using LibHac.Fs.Common;
using LibHac.Util;
using Xunit;

View file

@ -1,5 +1,7 @@
using LibHac.Common;
using LibHac.Fs.Common;
// ReSharper disable InconsistentNaming
using LibHac.Common;
using LibHac.Fs;
using Xunit;
namespace LibHac.Tests.Fs