Esempio n. 1
0
        protected override Result OpenFileImpl(out IFile file, string path, OpenMode mode)
        {
            file = default;
            path = PathTools.Normalize(path);

            if (!IsConcatenationFile(path))
            {
                return(BaseFileSystem.OpenFile(out file, path, mode));
            }

            int fileCount = GetSubFileCount(path);

            var files = new List <IFile>();

            for (int i = 0; i < fileCount; i++)
            {
                string filePath = GetSubFilePath(path, i);

                Result rc = BaseFileSystem.OpenFile(out IFile subFile, filePath, mode);
                if (rc.IsFailure())
                {
                    return(rc);
                }

                files.Add(subFile);
            }

            file = new ConcatenationFile(BaseFileSystem, path, files, SubFileSize, mode);
            return(Result.Success);
        }
Esempio n. 2
0
        protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
        {
            file = default;

            if (!IsConcatenationFile(path))
            {
                return(BaseFileSystem.OpenFile(out file, path, mode));
            }

            Result rc = GetSubFileCount(out int fileCount, path);

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

            var files = new List <IFile>(fileCount);

            for (int i = 0; i < fileCount; i++)
            {
                FsPath subFilePath;
                unsafe { _ = &subFilePath; } // workaround for CS0165

                rc = GetSubFilePath(subFilePath.Str, path, i);
                if (rc.IsFailure())
                {
                    return(rc);
                }

                rc = BaseFileSystem.OpenFile(out IFile subFile, subFilePath, mode);
                if (rc.IsFailure())
                {
                    return(rc);
                }

                files.Add(subFile);
            }

            file = new ConcatenationFile(BaseFileSystem, path, files, SubFileSize, mode);
            return(Result.Success);
        }
Esempio n. 3
0
        protected override Result DoOpenFile(out IFile file, U8Span path, OpenMode mode)
        {
            UnsafeHelpers.SkipParamInit(out file);

            if (!IsConcatenationFile(path))
            {
                return(BaseFileSystem.OpenFile(out file, path, mode));
            }

            Result rc = GetSubFileCount(out int fileCount, path);

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

            var files = new List <IFile>(fileCount);

            for (int i = 0; i < fileCount; i++)
            {
                Unsafe.SkipInit(out FsPath subFilePath);

                rc = GetSubFilePath(subFilePath.Str, path, i);
                if (rc.IsFailure())
                {
                    return(rc);
                }

                rc = BaseFileSystem.OpenFile(out IFile subFile, subFilePath, mode);
                if (rc.IsFailure())
                {
                    return(rc);
                }

                files.Add(subFile);
            }

            file = new ConcatenationFile(BaseFileSystem, path, files, SubFileSize, mode);
            return(Result.Success);
        }