Implement more OpenSaveDataInfoReader commands

This commit is contained in:
Alex Barney 2019-10-23 17:12:24 -05:00
parent 04b123f16e
commit bf8b975fa6
4 changed files with 69 additions and 6 deletions

View file

@ -89,7 +89,7 @@ namespace LibHac.Fs
Creating = 1,
State2 = 2,
MarkedForDeletion = 3,
State4 = 4,
Extending = 4,
}
public enum ImageDirectoryId

View file

@ -139,6 +139,6 @@
public static Result SubStorageNotInitialized => new Result(ModuleFs, 6902);
public static Result MountNameNotFound => new Result(ModuleFs, 6905);
public static Result Result6906 => new Result(ModuleFs, 6906);
public static Result SaveDataIsExtending => new Result(ModuleFs, 6906);
}
}

View file

@ -219,6 +219,30 @@ namespace LibHac.Fs.Shim
return result;
}
public static Result OpenSaveDataIterator(this FileSystemClient fs, out SaveDataIterator iterator, SaveDataSpaceId spaceId, ref SaveDataFilter filter)
{
var tempIterator = new SaveDataIterator();
SaveDataFilter tempFilter = filter;
Result result = fs.RunOperationWithAccessLog(LocalAccessLogMode.System,
() =>
{
IFileSystemProxy fsProxy = fs.GetFileSystemProxyServiceObject();
Result rc = fsProxy.OpenSaveDataInfoReaderWithFilter(out ISaveDataInfoReader reader, spaceId, ref tempFilter);
if (rc.IsFailure()) return rc;
tempIterator = new SaveDataIterator(fs, reader);
return Result.Success;
},
() => $", savedataspaceid: {spaceId}");
iterator = result.IsSuccess() ? tempIterator : default;
return result;
}
public static Result DisableAutoSaveDataCreation(this FileSystemClient fsClient)
{
IFileSystemProxy fsProxy = fsClient.GetFileSystemProxyServiceObject();

View file

@ -494,8 +494,8 @@ namespace LibHac.FsService
if (indexerValue.SpaceId != indexerSpaceId)
return ResultFs.TargetNotFound.Log();
if (indexerValue.State == SaveDataState.State4)
return ResultFs.Result6906.Log();
if (indexerValue.State == SaveDataState.Extending)
return ResultFs.SaveDataIsExtending.Log();
saveDataId = indexerValue.SaveDataId;
}
@ -703,7 +703,23 @@ namespace LibHac.FsService
public Result OpenSaveDataInfoReader(out ISaveDataInfoReader infoReader)
{
throw new NotImplementedException();
infoReader = default;
// Missing permission check
SaveDataIndexerReader indexReader = default;
try
{
Result rc = FsServer.SaveDataIndexerManager.GetSaveDataIndexer(out indexReader, SaveDataSpaceId.System);
if (rc.IsFailure()) return rc;
return indexReader.Indexer.OpenSaveDataInfoReader(out infoReader);
}
finally
{
indexReader.Dispose();
}
}
public Result OpenSaveDataInfoReaderBySaveDataSpaceId(out ISaveDataInfoReader infoReader, SaveDataSpaceId spaceId)
@ -741,7 +757,30 @@ namespace LibHac.FsService
public Result OpenSaveDataInfoReaderWithFilter(out ISaveDataInfoReader infoReader, SaveDataSpaceId spaceId,
ref SaveDataFilter filter)
{
throw new NotImplementedException();
infoReader = default;
// Missing permission check
SaveDataIndexerReader indexReader = default;
try
{
Result rc = FsServer.SaveDataIndexerManager.GetSaveDataIndexer(out indexReader, spaceId);
if (rc.IsFailure()) return rc;
rc = indexReader.Indexer.OpenSaveDataInfoReader(out ISaveDataInfoReader baseInfoReader);
if (rc.IsFailure()) return rc;
var filterInternal = new SaveDataFilterInternal(ref filter, spaceId);
infoReader = new SaveDataInfoFilterReader(baseInfoReader, ref filterInternal);
return Result.Success;
}
finally
{
indexReader.Dispose();
}
}
public Result FindSaveDataWithFilter(out long count, Span<byte> saveDataInfoBuffer, SaveDataSpaceId spaceId,