public Result OpenBisFileSystem(out IFileSystem fileSystem, ref FsPath rootPath, BisPartitionId partitionId) { fileSystem = default; // Missing permission check, speed emulation storage type wrapper, and FileSystemInterfaceAdapter Result rc = PathTools.Normalize(out U8Span normalizedPath, rootPath); if (rc.IsFailure()) { return(rc); } return(FsProxyCore.OpenBisFileSystem(out fileSystem, normalizedPath.ToString(), partitionId)); }
public Result OpenFileSystemWithId(out IFileSystem fileSystem, ref FsPath path, TitleId titleId, FileSystemProxyType type) { fileSystem = default; // Missing permission check, speed emulation storage type wrapper, and FileSystemInterfaceAdapter bool canMountSystemDataPrivate = false; var normalizer = new PathNormalizer(path, GetPathNormalizerOptions(path)); if (normalizer.Result.IsFailure()) { return(normalizer.Result); } // ReSharper disable once ConditionIsAlwaysTrueOrFalse return(FsProxyCore.OpenFileSystem(out fileSystem, normalizer.Path, type, canMountSystemDataPrivate, titleId)); }
private Result DeleteSaveDataFileSystemImpl2(SaveDataSpaceId spaceId, ulong saveDataId) { // missing: Check extra data flags for this value. Bit 3 bool doSecureDelete = false; Result rc = FsProxyCore.DeleteSaveDataMetaFiles(saveDataId, spaceId); if (rc.IsFailure() && !ResultFs.PathNotFound.Includes(rc)) { return(rc); } // ReSharper disable once ConditionIsAlwaysTrueOrFalse rc = FsProxyCore.DeleteSaveDataFileSystem(spaceId, saveDataId, doSecureDelete); if (rc.IsFailure() && !ResultFs.PathNotFound.Includes(rc)) { return(rc); } return(Result.Success); }
public Result OpenDeviceOperator(out IDeviceOperator deviceOperator) { // Missing permission check return(FsProxyCore.OpenDeviceOperator(out deviceOperator)); }
public Result OpenGameCardStorage(out IStorage storage, GameCardHandle handle, GameCardPartitionRaw partitionId) { // Missing permission check and StorageInterfaceAdapter return(FsProxyCore.OpenGameCardStorage(out storage, handle, partitionId)); }
public Result OpenSdCardFileSystem(out IFileSystem fileSystem) { // Missing permission check, speed emulation storage type wrapper, and FileSystemInterfaceAdapter return(FsProxyCore.OpenSdCardFileSystem(out fileSystem)); }
public Result OpenHostFileSystemWithOption(out IFileSystem fileSystem, ref FsPath path, MountHostOption option) { // Missing permission check return(FsProxyCore.OpenHostFileSystem(out fileSystem, new U8Span(path.Str), option.HasFlag(MountHostOption.PseudoCaseSensitive))); }
private Result OpenSaveDataFileSystemImpl(out IFileSystem fileSystem, out ulong saveDataId, SaveDataSpaceId spaceId, ref SaveDataAttribute attribute, bool openReadOnly, bool cacheExtraData) { fileSystem = default; saveDataId = default; bool hasFixedId = attribute.SaveDataId != 0 && attribute.UserId == UserId.Zero; if (hasFixedId) { saveDataId = attribute.SaveDataId; } else { SaveDataAttribute indexerKey = attribute; Result rc = FsServer.SaveDataIndexerManager.GetSaveDataIndexer(out SaveDataIndexerReader tmpReader, spaceId); using SaveDataIndexerReader reader = tmpReader; if (rc.IsFailure()) { return(rc); } rc = reader.Indexer.Get(out SaveDataIndexerValue indexerValue, ref indexerKey); if (rc.IsFailure()) { return(rc); } SaveDataSpaceId indexerSpaceId = GetSpaceIdForIndexer(spaceId); if (indexerValue.SpaceId != indexerSpaceId) { return(ResultFs.TargetNotFound.Log()); } if (indexerValue.State == SaveDataState.Extending) { return(ResultFs.SaveDataIsExtending.Log()); } saveDataId = indexerValue.SaveDataId; } Result saveFsResult = FsProxyCore.OpenSaveDataFileSystem(out fileSystem, spaceId, saveDataId, SaveDataRootPath.ToString(), openReadOnly, attribute.Type, cacheExtraData); if (saveFsResult.IsSuccess()) { return(Result.Success); } if (!ResultFs.PathNotFound.Includes(saveFsResult) && !ResultFs.TargetNotFound.Includes(saveFsResult)) { return(saveFsResult); } if (saveDataId != FileSystemServer.SaveIndexerId) { if (hasFixedId) { // todo: remove save indexer entry } } if (ResultFs.PathNotFound.Includes(saveFsResult)) { return(ResultFs.TargetNotFound.LogConverted(saveFsResult)); } return(saveFsResult); }
private Result CreateSaveDataFileSystemImpl(ref SaveDataAttribute attribute, ref SaveDataCreationInfo creationInfo, ref SaveMetaCreateInfo metaCreateInfo, ref OptionalHashSalt hashSalt, bool something) { ulong saveDataId = 0; bool isDeleteNeeded = false; Result rc; SaveDataIndexerReader reader = default; try { if (attribute.SaveDataId == FileSystemServer.SaveIndexerId) { saveDataId = FileSystemServer.SaveIndexerId; rc = FsProxyCore.DoesSaveDataExist(out bool saveExists, creationInfo.SpaceId, saveDataId); if (rc.IsSuccess() && saveExists) { return(ResultFs.PathAlreadyExists.Log()); } isDeleteNeeded = true; } else { rc = FsServer.SaveDataIndexerManager.GetSaveDataIndexer(out reader, creationInfo.SpaceId); if (rc.IsFailure()) { return(rc); } SaveDataAttribute indexerKey = attribute; if (attribute.SaveDataId != 0 && attribute.UserId == UserId.Zero) { saveDataId = attribute.SaveDataId; rc = reader.Indexer.AddSystemSaveData(ref indexerKey); } else { if (attribute.Type != SaveDataType.System && attribute.Type != SaveDataType.SystemBcat) { if (reader.Indexer.IsFull()) { return(ResultKvdb.TooLargeKeyOrDbFull.Log()); } } rc = reader.Indexer.Add(out saveDataId, ref indexerKey); } if (ResultFs.SaveDataPathAlreadyExists.Includes(rc)) { return(ResultFs.PathAlreadyExists.LogConverted(rc)); } isDeleteNeeded = true; rc = reader.Indexer.SetState(saveDataId, SaveDataState.Creating); if (rc.IsFailure()) { return(rc); } SaveDataSpaceId indexerSpaceId = GetSpaceIdForIndexer(creationInfo.SpaceId); rc = reader.Indexer.SetSpaceId(saveDataId, indexerSpaceId); if (rc.IsFailure()) { return(rc); } // todo: calculate size long size = 0; rc = reader.Indexer.SetSize(saveDataId, size); if (rc.IsFailure()) { return(rc); } rc = reader.Indexer.Commit(); if (rc.IsFailure()) { return(rc); } } rc = FsProxyCore.CreateSaveDataFileSystem(saveDataId, ref attribute, ref creationInfo, SaveDataRootPath, hashSalt, false); if (rc.IsFailure()) { if (!ResultFs.PathAlreadyExists.Includes(rc)) { return(rc); } rc = DeleteSaveDataFileSystemImpl2(creationInfo.SpaceId, saveDataId); if (rc.IsFailure()) { return(rc); } rc = FsProxyCore.CreateSaveDataFileSystem(saveDataId, ref attribute, ref creationInfo, SaveDataRootPath, hashSalt, false); if (rc.IsFailure()) { return(rc); } } if (metaCreateInfo.Type != SaveDataMetaType.None) { rc = FsProxyCore.CreateSaveDataMetaFile(saveDataId, creationInfo.SpaceId, metaCreateInfo.Type, metaCreateInfo.Size); if (rc.IsFailure()) { return(rc); } if (metaCreateInfo.Type == SaveDataMetaType.Thumbnail) { rc = FsProxyCore.OpenSaveDataMetaFile(out IFile metaFile, saveDataId, creationInfo.SpaceId, metaCreateInfo.Type); using (metaFile) { if (rc.IsFailure()) { return(rc); } ReadOnlySpan <byte> metaFileData = stackalloc byte[0x20]; rc = metaFile.Write(0, metaFileData, WriteOption.Flush); if (rc.IsFailure()) { return(rc); } } } } if (attribute.SaveDataId == FileSystemServer.SaveIndexerId || something) { isDeleteNeeded = false; return(Result.Success); } rc = reader.Indexer.SetState(saveDataId, SaveDataState.Normal); if (rc.IsFailure()) { return(rc); } rc = reader.Indexer.Commit(); if (rc.IsFailure()) { return(rc); } isDeleteNeeded = false; return(Result.Success); } finally { // Revert changes if an error happened in the middle of creation if (isDeleteNeeded) { DeleteSaveDataFileSystemImpl2(creationInfo.SpaceId, saveDataId).IgnoreResult(); if (reader.IsInitialized && saveDataId != FileSystemServer.SaveIndexerId) { rc = reader.Indexer.GetBySaveDataId(out SaveDataIndexerValue value, saveDataId); if (rc.IsSuccess() && value.SpaceId == creationInfo.SpaceId) { reader.Indexer.Delete(saveDataId).IgnoreResult(); reader.Indexer.Commit().IgnoreResult(); } } } reader.Dispose(); } }