Пример #1
0
        protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
        {
            file = default;

            FsPath normalizedPath;

            unsafe { _ = &normalizedPath; } // workaround for CS0165

            Result rc = PathTool.Normalize(normalizedPath.Str, out _, path, false, false);

            if (rc.IsFailure())
            {
                return(rc);
            }

            if (!FileTable.TryOpenFile(normalizedPath, out SaveFileInfo fileInfo))
            {
                return(ResultFs.PathNotFound.Log());
            }

            AllocationTableStorage storage = OpenFatStorage(fileInfo.StartBlock);

            file = new SaveDataFile(storage, normalizedPath, FileTable, fileInfo.Length, mode);

            return(Result.Success);
        }
Пример #2
0
 public SaveDataFile(AllocationTableStorage baseStorage, U8Span path, HierarchicalSaveFileTable fileTable, long size, OpenMode mode)
 {
     Mode        = mode;
     BaseStorage = baseStorage;
     Path        = path.ToU8String();
     FileTable   = fileTable;
     Size        = size;
 }
Пример #3
0
        public SaveDataFileSystemCore(IStorage storage, IStorage allocationTable, IStorage header)
        {
            HeaderStorage   = header;
            BaseStorage     = storage;
            AllocationTable = new AllocationTable(allocationTable, header.Slice(0x18, 0x30));

            Header = new SaveHeader(HeaderStorage);

            AllocationTableStorage dirTableStorage  = OpenFatStorage(AllocationTable.Header.DirectoryTableBlock);
            AllocationTableStorage fileTableStorage = OpenFatStorage(AllocationTable.Header.FileTableBlock);

            FileTable = new HierarchicalSaveFileTable(dirTableStorage, fileTableStorage);
        }
Пример #4
0
        protected override Result OpenFileImpl(out IFile file, string path, OpenMode mode)
        {
            file = default;
            path = PathTools.Normalize(path);

            if (!FileTable.TryOpenFile(path, out SaveFileInfo fileInfo))
            {
                return(ResultFs.PathNotFound.Log());
            }

            AllocationTableStorage storage = OpenFatStorage(fileInfo.StartBlock);

            file = new SaveDataFile(storage, path, FileTable, fileInfo.Length, mode);

            return(Result.Success);
        }
        protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
        {
            UnsafeHelpers.SkipParamInit(out file);

            Unsafe.SkipInit(out FsPath normalizedPath);

            Result rc = PathTool.Normalize(normalizedPath.Str, out _, path, false, false);

            if (rc.IsFailure())
            {
                return(rc);
            }

            if (!FileTable.TryOpenFile(normalizedPath, out SaveFileInfo fileInfo))
            {
                return(ResultFs.PathNotFound.Log());
            }

            AllocationTableStorage storage = OpenFatStorage(fileInfo.StartBlock);

            file = new SaveDataFile(storage, normalizedPath, FileTable, fileInfo.Length, mode);

            return(Result.Success);
        }