Make EmulatedSdFileSystemCreator config easier

Also make unintentionally internal classes public and enforce var style
This commit is contained in:
Alex Barney 2019-10-24 13:17:08 -05:00
parent f3b5cad94b
commit 172817a7d5
3 changed files with 20 additions and 8 deletions

View file

@ -3,20 +3,26 @@ using LibHac.Fs;
namespace LibHac.FsService.Creators
{
class EmulatedSdFileSystemCreator : ISdFileSystemCreator
public class EmulatedSdFileSystemCreator : ISdFileSystemCreator
{
private const string DefaultPath = "/sdcard";
public IFileSystem RootFileSystem { get; set; }
public string Path { get; set; }
private IFileSystem RootFileSystem { get; }
private string Path { get; }
public IFileSystem SdCardFileSystem { get; set; }
private IFileSystem SdCardFileSystem { get; set; }
public EmulatedSdFileSystemCreator(IFileSystem rootFileSystem)
{
RootFileSystem = rootFileSystem;
}
public EmulatedSdFileSystemCreator(IFileSystem rootFileSystem, string path)
{
RootFileSystem = rootFileSystem;
Path = path;
}
public Result Create(out IFileSystem fileSystem)
{
fileSystem = default;
@ -37,7 +43,13 @@ namespace LibHac.FsService.Creators
// Todo: Add ProxyFileSystem?
return Util.CreateSubFileSystem(out fileSystem, RootFileSystem, path, true);
Result rc = Util.CreateSubFileSystem(out IFileSystem sdFileSystem, RootFileSystem, path, true);
if (rc.IsFailure()) return rc;
SdCardFileSystem = sdFileSystem;
fileSystem = sdFileSystem;
return Result.Success;
}
public Result Format(bool closeOpenEntries)

View file

@ -3,7 +3,7 @@ using LibHac.Fs;
namespace LibHac.FsService
{
class EmulatedDeviceOperator : IDeviceOperator
public class EmulatedDeviceOperator : IDeviceOperator
{
private EmulatedGameCard GameCard { get; set; }

View file

@ -234,9 +234,9 @@ namespace hactoolnet
PrintItem(sb, colLen, "TitleID:", $"{nca.Header.TitleId:X16}");
if (nca.CanOpenSection(NcaSectionType.Code)) {
IFileSystem fs = nca.OpenFileSystem(NcaSectionType.Code, IntegrityCheckLevel.None);
Result r = fs.OpenFile(out var file, "/main.npdm", OpenMode.Read);
Result r = fs.OpenFile(out IFile file, "/main.npdm", OpenMode.Read);
if (r.IsSuccess()) {
NpdmBinary npdm = new NpdmBinary(file.AsStream(), null);
var npdm = new NpdmBinary(file.AsStream(), null);
PrintItem(sb, colLen, "Title Name:", npdm.TitleName);
}
}