예제 #1
0
 public SaveDataDirectory(SaveDataFileSystemCore fs, SaveFindPosition position, OpenDirectoryMode mode)
 {
     ParentFileSystem = fs;
     InitialPosition  = position;
     _currentPosition = position;
     Mode             = mode;
 }
예제 #2
0
        public void FsTrim()
        {
            MetaRemapStorage.FsTrim();
            DataRemapStorage.FsTrim();
            DuplexStorage.FsTrim();
            JournalStorage.FsTrim();
            CoreDataIvfcStorage.FsTrim();
            FatIvfcStorage?.FsTrim();
            SaveDataFileSystemCore.FsTrim();

            int unusedHeaderOffset = IsFirstHeaderInUse ? 0x4000 : 0;

            BaseStorage.Slice(unusedHeaderOffset, 0x4000).Fill(TrimFillValue);
        }
예제 #3
0
        protected override Result OpenDirectoryImpl(out IDirectory directory, string path, OpenDirectoryMode mode)
        {
            Result result = SaveDataFileSystemCore.OpenDirectory(out directory, path, mode);

            return(SaveResults.ConvertToExternalResult(result));
        }
예제 #4
0
        protected override Result DeleteFileImpl(string path)
        {
            Result result = SaveDataFileSystemCore.DeleteFile(path);

            return(SaveResults.ConvertToExternalResult(result));
        }
예제 #5
0
        protected override Result CleanDirectoryRecursivelyImpl(string path)
        {
            Result result = SaveDataFileSystemCore.CleanDirectoryRecursively(path);

            return(SaveResults.ConvertToExternalResult(result));
        }
예제 #6
0
        protected override Result CreateFileImpl(string path, long size, CreateFileOptions options)
        {
            Result result = SaveDataFileSystemCore.CreateFile(path, size, options);

            return(SaveResults.ConvertToExternalResult(result));
        }
예제 #7
0
        protected override Result GetFreeSpaceSizeImpl(out long freeSpace, U8Span path)
        {
            Result result = SaveDataFileSystemCore.GetFreeSpaceSize(out freeSpace, path);

            return(SaveResults.ConvertToExternalResult(result).LogConverted(result));
        }
예제 #8
0
        protected override Result GetEntryTypeImpl(out DirectoryEntryType entryType, string path)
        {
            Result result = SaveDataFileSystemCore.GetEntryType(out entryType, path);

            return(SaveResults.ConvertToExternalResult(result));
        }
예제 #9
0
        protected override Result DoRenameFile(U8Span oldPath, U8Span newPath)
        {
            Result result = SaveDataFileSystemCore.RenameFile(oldPath, newPath);

            return(SaveResults.ConvertToExternalResult(result).LogConverted(result));
        }
예제 #10
0
        protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
        {
            Result result = SaveDataFileSystemCore.OpenFile(out file, path, mode);

            return(SaveResults.ConvertToExternalResult(result).LogConverted(result));
        }
예제 #11
0
        protected override Result DoOpenDirectory(out IDirectory directory, U8Span path, OpenDirectoryMode mode)
        {
            Result result = SaveDataFileSystemCore.OpenDirectory(out directory, path, mode);

            return(SaveResults.ConvertToExternalResult(result).LogConverted(result));
        }
예제 #12
0
        protected override Result DoDeleteFile(U8Span path)
        {
            Result result = SaveDataFileSystemCore.DeleteFile(path);

            return(SaveResults.ConvertToExternalResult(result).LogConverted(result));
        }
예제 #13
0
        protected override Result DoCleanDirectoryRecursively(U8Span path)
        {
            Result result = SaveDataFileSystemCore.CleanDirectoryRecursively(path);

            return(SaveResults.ConvertToExternalResult(result).LogConverted(result));
        }
예제 #14
0
        protected override Result DoCreateFile(U8Span path, long size, CreateFileOptions options)
        {
            Result result = SaveDataFileSystemCore.CreateFile(path, size, options);

            return(SaveResults.ConvertToExternalResult(result).LogConverted(result));
        }
예제 #15
0
        protected override Result OpenFileImpl(out IFile file, string path, OpenMode mode)
        {
            Result result = SaveDataFileSystemCore.OpenFile(out file, path, mode);

            return(SaveResults.ConvertToExternalResult(result));
        }
예제 #16
0
        protected override Result RenameFileImpl(string oldPath, string newPath)
        {
            Result result = SaveDataFileSystemCore.RenameFile(oldPath, newPath);

            return(SaveResults.ConvertToExternalResult(result));
        }
예제 #17
0
        protected override Result DoGetEntryType(out DirectoryEntryType entryType, U8Span path)
        {
            Result result = SaveDataFileSystemCore.GetEntryType(out entryType, path);

            return(SaveResults.ConvertToExternalResult(result).LogConverted(result));
        }
예제 #18
0
        protected override Result GetTotalSpaceSizeImpl(out long totalSpace, string path)
        {
            Result result = SaveDataFileSystemCore.GetTotalSpaceSize(out totalSpace, path);

            return(SaveResults.ConvertToExternalResult(result));
        }
예제 #19
0
        protected override Result DoGetTotalSpaceSize(out long totalSpace, U8Span path)
        {
            Result result = SaveDataFileSystemCore.GetTotalSpaceSize(out totalSpace, path);

            return(SaveResults.ConvertToExternalResult(result).LogConverted(result));
        }
예제 #20
0
        public SaveDataFileSystem(Keyset keyset, IStorage storage, IntegrityCheckLevel integrityCheckLevel, bool leaveOpen)
        {
            BaseStorage = storage;
            LeaveOpen   = leaveOpen;
            Keyset      = keyset;

            var headerA = new Header(BaseStorage, keyset);
            var headerB = new Header(BaseStorage.Slice(0x4000), keyset);

            if (headerA.HeaderHashValidity == Validity.Valid)
            {
                IsFirstHeaderInUse = true;
            }
            else if (headerB.HeaderHashValidity == Validity.Valid)
            {
                IsFirstHeaderInUse = false;
            }
            else
            {
                ThrowHelper.ThrowResult(ResultFs.InvalidSaveDataHeader, "Savedata header is not valid.");
            }

            Header = IsFirstHeaderInUse ? headerA : headerB;

            FsLayout layout = Header.Layout;

            IStorage dataRemapBase        = BaseStorage.Slice(layout.FileMapDataOffset, layout.FileMapDataSize);
            IStorage dataRemapEntries     = BaseStorage.Slice(layout.FileMapEntryOffset, layout.FileMapEntrySize);
            IStorage metadataRemapEntries = BaseStorage.Slice(layout.MetaMapEntryOffset, layout.MetaMapEntrySize);

            DataRemapStorage = new RemapStorage(dataRemapBase, Header.MainRemapHeader, dataRemapEntries, leaveOpen);

            DuplexStorage = InitDuplexStorage(DataRemapStorage, Header);

            MetaRemapStorage = new RemapStorage(DuplexStorage, Header.MetaDataRemapHeader, metadataRemapEntries, leaveOpen);

            var journalMapInfo = new JournalMapParams
            {
                MapStorage          = MetaRemapStorage.Slice(layout.JournalMapTableOffset, layout.JournalMapTableSize),
                PhysicalBlockBitmap = MetaRemapStorage.Slice(layout.JournalPhysicalBitmapOffset, layout.JournalPhysicalBitmapSize),
                VirtualBlockBitmap  = MetaRemapStorage.Slice(layout.JournalVirtualBitmapOffset, layout.JournalVirtualBitmapSize),
                FreeBlockBitmap     = MetaRemapStorage.Slice(layout.JournalFreeBitmapOffset, layout.JournalFreeBitmapSize),
            };

            IStorage journalData = DataRemapStorage.Slice(layout.JournalDataOffset,
                                                          layout.JournalDataSizeB + layout.JournalSize);

            JournalStorage = new JournalStorage(journalData, Header.JournalHeader, journalMapInfo, leaveOpen);

            CoreDataIvfcStorage = InitJournalIvfcStorage(integrityCheckLevel);

            IStorage fatStorage = MetaRemapStorage.Slice(layout.FatOffset, layout.FatSize);

            if (Header.Layout.Version >= 0x50000)
            {
                FatIvfcStorage = InitFatIvfcStorage(integrityCheckLevel);
                fatStorage     = FatIvfcStorage;
            }

            SaveDataFileSystemCore = new SaveDataFileSystemCore(CoreDataIvfcStorage, fatStorage, Header.SaveHeader);
        }
예제 #21
0
        protected override Result CreateDirectoryImpl(string path)
        {
            Result result = SaveDataFileSystemCore.CreateDirectory(path);

            return(SaveResults.ConvertToExternalResult(result));
        }