Rename some save enum/struct fields

This commit is contained in:
Alex Barney 2021-12-29 10:13:42 -07:00
parent 5013e7d2ec
commit 5380902376
9 changed files with 55 additions and 55 deletions

View File

@ -253,7 +253,7 @@ public static class ApplicationSaveDataManagement
} }
else if (targetMedia == CacheStorageTargetMedia.SdCard) else if (targetMedia == CacheStorageTargetMedia.SdCard)
{ {
rc = TryCreateCacheStorage(fs, out requiredSizeLocal, SaveDataSpaceId.SdCache, applicationId, rc = TryCreateCacheStorage(fs, out requiredSizeLocal, SaveDataSpaceId.SdUser, applicationId,
saveDataOwnerId, index, dataSize, journalSize, allowExisting); saveDataOwnerId, index, dataSize, journalSize, allowExisting);
if (rc.IsFailure()) return rc; if (rc.IsFailure()) return rc;
} }
@ -265,7 +265,7 @@ public static class ApplicationSaveDataManagement
{ {
target = CacheStorageTargetMedia.SdCard; target = CacheStorageTargetMedia.SdCard;
Result CreateFuncSdCard() => fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdCache, Result CreateFuncSdCard() => fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdUser,
saveDataOwnerId, index, dataSize, journalSize, SaveDataFlags.None); saveDataOwnerId, index, dataSize, journalSize, SaveDataFlags.None);
rc = CreateSaveData(fs, CreateFuncSdCard, ref requiredSizeLocal, 0x4000, dataSize, journalSize); rc = CreateSaveData(fs, CreateFuncSdCard, ref requiredSizeLocal, 0x4000, dataSize, journalSize);
@ -420,7 +420,7 @@ public static class ApplicationSaveDataManagement
if (fs.IsSdCardAccessible()) if (fs.IsSdCardAccessible())
{ {
Result rc = fs.FindSaveDataWithFilter(out _, SaveDataSpaceId.SdCache, in filter); Result rc = fs.FindSaveDataWithFilter(out _, SaveDataSpaceId.SdUser, in filter);
if (rc.IsFailure() && !ResultFs.TargetNotFound.Includes(rc)) return rc; if (rc.IsFailure() && !ResultFs.TargetNotFound.Includes(rc)) return rc;
if (rc.IsSuccess()) if (rc.IsSuccess())
@ -471,4 +471,4 @@ public static class ApplicationSaveDataManagement
{ {
return new UserId(uid.Id.High, uid.Id.Low); return new UserId(uid.Id.High, uid.Id.Low);
} }
} }

View File

@ -52,7 +52,7 @@ public enum SaveDataSpaceId : byte
User = 1, User = 1,
SdSystem = 2, SdSystem = 2,
Temporary = 3, Temporary = 3,
SdCache = 4, SdUser = 4,
ProperSystem = 100, ProperSystem = 100,
SafeMode = 101, SafeMode = 101,
BisAuto = 127 BisAuto = 127
@ -260,5 +260,5 @@ public enum SdCardSpeedMode
Sdr50 = 5, Sdr50 = 5,
Sdr104 = 6, Sdr104 = 6,
Ddr50 = 7, Ddr50 = 7,
Unknown = 8, Unknown = 8
} }

View File

@ -118,7 +118,7 @@ public struct SaveDataCreationInfo
[FieldOffset(0x18)] public ulong OwnerId; [FieldOffset(0x18)] public ulong OwnerId;
[FieldOffset(0x20)] public SaveDataFlags Flags; [FieldOffset(0x20)] public SaveDataFlags Flags;
[FieldOffset(0x24)] public SaveDataSpaceId SpaceId; [FieldOffset(0x24)] public SaveDataSpaceId SpaceId;
[FieldOffset(0x25)] public bool Field25; [FieldOffset(0x25)] public bool IsPseudoSaveData;
public static Result Make(out SaveDataCreationInfo creationInfo, long size, long journalSize, ulong ownerId, public static Result Make(out SaveDataCreationInfo creationInfo, long size, long journalSize, ulong ownerId,
SaveDataFlags flags, SaveDataSpaceId spaceId) SaveDataFlags flags, SaveDataSpaceId spaceId)
@ -132,7 +132,7 @@ public struct SaveDataCreationInfo
tempCreationInfo.OwnerId = ownerId; tempCreationInfo.OwnerId = ownerId;
tempCreationInfo.Flags = flags; tempCreationInfo.Flags = flags;
tempCreationInfo.SpaceId = spaceId; tempCreationInfo.SpaceId = spaceId;
tempCreationInfo.Field25 = false; tempCreationInfo.IsPseudoSaveData = false;
if (!SaveDataTypesValidity.IsValid(in tempCreationInfo)) if (!SaveDataTypesValidity.IsValid(in tempCreationInfo))
return ResultFs.InvalidArgument.Log(); return ResultFs.InvalidArgument.Log();
@ -331,7 +331,7 @@ internal static class SaveDataTypesValidity
public static bool IsValid(in SaveDataSpaceId spaceId) public static bool IsValid(in SaveDataSpaceId spaceId)
{ {
return (uint)spaceId <= (uint)SaveDataSpaceId.SdCache || spaceId == SaveDataSpaceId.ProperSystem || return (uint)spaceId <= (uint)SaveDataSpaceId.SdUser || spaceId == SaveDataSpaceId.ProperSystem ||
spaceId == SaveDataSpaceId.SafeMode; spaceId == SaveDataSpaceId.SafeMode;
} }

View File

@ -102,7 +102,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
break; break;
case SaveDataSpaceId.User: case SaveDataSpaceId.User:
case SaveDataSpaceId.Temporary: case SaveDataSpaceId.Temporary:
case SaveDataSpaceId.SdCache: case SaveDataSpaceId.SdUser:
if (!programInfo.AccessControl.CanCall(OperationType.OpenSaveDataInfoReader)) if (!programInfo.AccessControl.CanCall(OperationType.OpenSaveDataInfoReader))
return ResultFs.PermissionDenied.Log(); return ResultFs.PermissionDenied.Log();
break; break;
@ -1751,7 +1751,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
Result rc = GetProgramInfo(out ProgramInfo programInfo); Result rc = GetProgramInfo(out ProgramInfo programInfo);
if (rc.IsFailure()) return rc; if (rc.IsFailure()) return rc;
if (spaceId != SaveDataSpaceId.SdCache && spaceId != SaveDataSpaceId.User) if (spaceId != SaveDataSpaceId.SdUser && spaceId != SaveDataSpaceId.User)
return ResultFs.InvalidSaveDataSpaceId.Log(); return ResultFs.InvalidSaveDataSpaceId.Log();
using var filterReader = new UniqueRef<SaveDataInfoFilterReader>(); using var filterReader = new UniqueRef<SaveDataInfoFilterReader>();
@ -1810,12 +1810,12 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
// Cache storage on the SD card will always take priority over case storage in NAND // Cache storage on the SD card will always take priority over case storage in NAND
if (_serviceImpl.IsSdCardAccessible()) if (_serviceImpl.IsSdCardAccessible())
{ {
rc = SaveExists(out bool existsOnSdCard, SaveDataSpaceId.SdCache); rc = SaveExists(out bool existsOnSdCard, SaveDataSpaceId.SdUser);
if (rc.IsFailure()) return rc; if (rc.IsFailure()) return rc;
if (existsOnSdCard) if (existsOnSdCard)
{ {
spaceId = SaveDataSpaceId.SdCache; spaceId = SaveDataSpaceId.SdUser;
return Result.Success; return Result.Success;
} }
} }
@ -2207,7 +2207,7 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
return StorageType.Bis | StorageType.SdCard | StorageType.Usb; return StorageType.Bis | StorageType.SdCard | StorageType.Usb;
if (type == SaveDataType.System || if (type == SaveDataType.System ||
spaceId != SaveDataSpaceId.SdSystem && spaceId != SaveDataSpaceId.SdCache) spaceId != SaveDataSpaceId.SdSystem && spaceId != SaveDataSpaceId.SdUser)
return StorageType.Bis; return StorageType.Bis;
return StorageType.SdCard | StorageType.Usb; return StorageType.SdCard | StorageType.Usb;
@ -2257,4 +2257,4 @@ internal class SaveDataFileSystemService : ISaveDataTransferCoreInterface, ISave
_openEntryCountSemaphore.Dispose(); _openEntryCountSemaphore.Dispose();
_saveDataMountCountSemaphore.Dispose(); _saveDataMountCountSemaphore.Dispose();
} }
} }

View File

@ -659,37 +659,37 @@ public class SaveDataFileSystemServiceImpl
return Result.Success; return Result.Success;
case SaveDataSpaceId.SdSystem: case SaveDataSpaceId.SdSystem:
case SaveDataSpaceId.SdCache: case SaveDataSpaceId.SdUser:
{ {
rc = _config.BaseFsService.OpenSdCardProxyFileSystem(ref baseFileSystem.Ref(), true); rc = _config.BaseFsService.OpenSdCardProxyFileSystem(ref baseFileSystem.Ref(), true);
if (rc.IsFailure()) return rc.Miss(); if (rc.IsFailure()) return rc.Miss();
// Hack around error CS8350. // Hack around error CS8350.
const int bufferLength = 0x40; const int bufferLength = 0x40;
Span<byte> buffer = stackalloc byte[bufferLength]; Span<byte> buffer = stackalloc byte[bufferLength];
ref byte bufferRef = ref MemoryMarshal.GetReference(buffer); ref byte bufferRef = ref MemoryMarshal.GetReference(buffer);
Span<byte> pathParentBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength); Span<byte> pathParentBuffer = MemoryMarshal.CreateSpan(ref bufferRef, bufferLength);
using var pathParent = new Path(); using var pathParent = new Path();
rc = PathFunctions.SetUpFixedPathSingleEntry(ref pathParent.Ref(), pathParentBuffer, rc = PathFunctions.SetUpFixedPathSingleEntry(ref pathParent.Ref(), pathParentBuffer,
CommonPaths.SdCardNintendoRootDirectoryName); CommonPaths.SdCardNintendoRootDirectoryName);
if (rc.IsFailure()) return rc.Miss(); if (rc.IsFailure()) return rc.Miss();
using var pathSdRoot = new Path(); using var pathSdRoot = new Path();
rc = pathSdRoot.Combine(in pathParent, in basePath); rc = pathSdRoot.Combine(in pathParent, in basePath);
if (rc.IsFailure()) return rc.Miss(); if (rc.IsFailure()) return rc.Miss();
using SharedRef<IFileSystem> tempFileSystem = using SharedRef<IFileSystem> tempFileSystem =
SharedRef<IFileSystem>.CreateMove(ref baseFileSystem.Ref()); SharedRef<IFileSystem>.CreateMove(ref baseFileSystem.Ref());
rc = Utility.WrapSubDirectory(ref baseFileSystem.Ref(), ref tempFileSystem.Ref(), in pathSdRoot, createIfMissing); rc = Utility.WrapSubDirectory(ref baseFileSystem.Ref(), ref tempFileSystem.Ref(), in pathSdRoot, createIfMissing);
if (rc.IsFailure()) return rc.Miss(); if (rc.IsFailure()) return rc.Miss();
rc = _config.EncryptedFsCreator.Create(ref outFileSystem, ref baseFileSystem.Ref(), rc = _config.EncryptedFsCreator.Create(ref outFileSystem, ref baseFileSystem.Ref(),
IEncryptedFileSystemCreator.KeyId.Save, in _encryptionSeed); IEncryptedFileSystemCreator.KeyId.Save, in _encryptionSeed);
if (rc.IsFailure()) return rc.Miss(); if (rc.IsFailure()) return rc.Miss();
return Result.Success; return Result.Success;
} }
case SaveDataSpaceId.ProperSystem: case SaveDataSpaceId.ProperSystem:
rc = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(), rc = _config.BaseFsService.OpenBisFileSystem(ref baseFileSystem.Ref(),
@ -721,7 +721,7 @@ public class SaveDataFileSystemServiceImpl
_config.SaveFsCreator.SetSdCardEncryptionSeed(seed.Value); _config.SaveFsCreator.SetSdCardEncryptionSeed(seed.Value);
_config.SaveIndexerManager.InvalidateIndexer(SaveDataSpaceId.SdSystem); _config.SaveIndexerManager.InvalidateIndexer(SaveDataSpaceId.SdSystem);
_config.SaveIndexerManager.InvalidateIndexer(SaveDataSpaceId.SdCache); _config.SaveIndexerManager.InvalidateIndexer(SaveDataSpaceId.SdUser);
return Result.Success; return Result.Success;
} }
@ -817,4 +817,4 @@ public class SaveDataFileSystemServiceImpl
{ {
_config.SaveIndexerManager.ResetIndexer(SaveDataSpaceId.Temporary); _config.SaveIndexerManager.ResetIndexer(SaveDataSpaceId.Temporary);
} }
} }

View File

@ -85,7 +85,7 @@ internal class SaveDataIndexerManager : ISaveDataIndexerManager
indexer = _bisIndexer.Indexer; indexer = _bisIndexer.Indexer;
break; break;
case SaveDataSpaceId.SdSystem: case SaveDataSpaceId.SdSystem:
case SaveDataSpaceId.SdCache: case SaveDataSpaceId.SdUser:
// ReSharper doesn't realize that UniqueLock locks the indexer's lock object // ReSharper doesn't realize that UniqueLock locks the indexer's lock object
// ReSharper disable InconsistentlySynchronizedField // ReSharper disable InconsistentlySynchronizedField
indexerLock = new UniqueLock(_sdCardIndexer.Locker); indexerLock = new UniqueLock(_sdCardIndexer.Locker);
@ -176,7 +176,7 @@ internal class SaveDataIndexerManager : ISaveDataIndexerManager
// Note: Nintendo doesn't lock when doing this operation // Note: Nintendo doesn't lock when doing this operation
lock (_sdCardIndexer.Locker) lock (_sdCardIndexer.Locker)
{ {
if (spaceId != SaveDataSpaceId.SdCache && spaceId != SaveDataSpaceId.SdSystem) if (spaceId != SaveDataSpaceId.SdUser && spaceId != SaveDataSpaceId.SdSystem)
{ {
Abort.UnexpectedDefault(); Abort.UnexpectedDefault();
} }
@ -252,4 +252,4 @@ public class SaveDataIndexerAccessor : IDisposable
{ {
_locker.Dispose(); _locker.Dispose();
} }
} }

View File

@ -140,7 +140,7 @@ public class ApplicationSaveDataManagementTests
Assert.Equal(CacheStorageTargetMedia.SdCard, target); Assert.Equal(CacheStorageTargetMedia.SdCard, target);
using var iterator = new UniqueRef<SaveDataIterator>(); using var iterator = new UniqueRef<SaveDataIterator>();
fs.OpenSaveDataIterator(ref iterator.Ref(), SaveDataSpaceId.SdCache); fs.OpenSaveDataIterator(ref iterator.Ref(), SaveDataSpaceId.SdUser);
var info = new SaveDataInfo[2]; var info = new SaveDataInfo[2];
Assert.Success(iterator.Get.ReadSaveDataInfo(out long entriesRead, info)); Assert.Success(iterator.Get.ReadSaveDataInfo(out long entriesRead, info));
@ -208,4 +208,4 @@ public class ApplicationSaveDataManagementTests
Assert.Success(fs.GetCacheStorageTargetMedia(out CacheStorageTargetMedia target, new Ncm.ApplicationId(11))); Assert.Success(fs.GetCacheStorageTargetMedia(out CacheStorageTargetMedia target, new Ncm.ApplicationId(11)));
Assert.Equal(CacheStorageTargetMedia.None, target); Assert.Equal(CacheStorageTargetMedia.None, target);
} }
} }

View File

@ -25,7 +25,7 @@ public class SaveData
var applicationId = new Ncm.ApplicationId(1); var applicationId = new Ncm.ApplicationId(1);
FileSystemClient fs = FileSystemServerFactory.CreateClient(true); FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdCache, applicationId.Value, 0, 0, SaveDataFlags.None); fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdUser, applicationId.Value, 0, 0, SaveDataFlags.None);
fs.MountCacheStorage("cache".ToU8Span(), applicationId); fs.MountCacheStorage("cache".ToU8Span(), applicationId);
fs.CreateFile("cache:/file".ToU8Span(), 0); fs.CreateFile("cache:/file".ToU8Span(), 0);
@ -43,7 +43,7 @@ public class SaveData
var applicationId = new Ncm.ApplicationId(1); var applicationId = new Ncm.ApplicationId(1);
FileSystemClient fs = FileSystemServerFactory.CreateClient(true); FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
Assert.Success(fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdCache, applicationId.Value, 0, 0, SaveDataFlags.None)); Assert.Success(fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdUser, applicationId.Value, 0, 0, SaveDataFlags.None));
Assert.Success(fs.MountCacheStorage("cache".ToU8Span(), applicationId)); Assert.Success(fs.MountCacheStorage("cache".ToU8Span(), applicationId));
fs.CreateFile("cache:/sd".ToU8Span(), 0); fs.CreateFile("cache:/sd".ToU8Span(), 0);
fs.Commit("cache".ToU8Span()); fs.Commit("cache".ToU8Span());
@ -64,4 +64,4 @@ public class SaveData
Assert.Success(fs.GetEntryType(out _, "cache:/sd".ToU8Span())); Assert.Success(fs.GetEntryType(out _, "cache:/sd".ToU8Span()));
Assert.Failure(fs.GetEntryType(out _, "cache:/bis".ToU8Span())); Assert.Failure(fs.GetEntryType(out _, "cache:/bis".ToU8Span()));
} }
} }

View File

@ -36,10 +36,10 @@ public class SaveDataManagement
var applicationId = new Ncm.ApplicationId(1); var applicationId = new Ncm.ApplicationId(1);
FileSystemClient fs = FileSystemServerFactory.CreateClient(true); FileSystemClient fs = FileSystemServerFactory.CreateClient(true);
Assert.Success(fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdCache, applicationId.Value, 0, 0, SaveDataFlags.None)); Assert.Success(fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdUser, applicationId.Value, 0, 0, SaveDataFlags.None));
using var iterator = new UniqueRef<SaveDataIterator>(); using var iterator = new UniqueRef<SaveDataIterator>();
fs.OpenSaveDataIterator(ref iterator.Ref(), SaveDataSpaceId.SdCache); fs.OpenSaveDataIterator(ref iterator.Ref(), SaveDataSpaceId.SdUser);
var info = new SaveDataInfo[2]; var info = new SaveDataInfo[2];
iterator.Get.ReadSaveDataInfo(out long entriesRead, info); iterator.Get.ReadSaveDataInfo(out long entriesRead, info);
@ -54,7 +54,7 @@ public class SaveDataManagement
var applicationId = new Ncm.ApplicationId(1); var applicationId = new Ncm.ApplicationId(1);
FileSystemClient fs = FileSystemServerFactory.CreateClient(false); FileSystemClient fs = FileSystemServerFactory.CreateClient(false);
Assert.Result(ResultFs.PortSdCardNoDevice, fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdCache, applicationId.Value, 0, 0, SaveDataFlags.None)); Assert.Result(ResultFs.PortSdCardNoDevice, fs.CreateCacheStorage(applicationId, SaveDataSpaceId.SdUser, applicationId.Value, 0, 0, SaveDataFlags.None));
} }
[Fact] [Fact]
@ -602,4 +602,4 @@ public class SaveDataManagement
return Result.Success; return Result.Success;
} }
} }