Beispiel #1
0
        public IndirectStorage(IStorage bucketTreeHeader, IStorage bucketTreeData, bool leaveOpen, params IStorage[] sources)
        {
            Sources.AddRange(sources);

            if (!leaveOpen)
            {
                ToDispose.AddRange(sources);
            }

            BucketTree = new BucketTree <RelocationEntry>(bucketTreeHeader, bucketTreeData);

            RelocationEntries = BucketTree.GetEntryList();
            RelocationOffsets = RelocationEntries.Select(x => x.Offset).ToList();

            Length = BucketTree.BucketOffsets.OffsetEnd;
        }
Beispiel #2
0
        internal ConcatenationFile(IList <IFile> sources, long splitFileSize, OpenMode mode)
        {
            Sources       = sources.ToArray();
            SplitFileSize = splitFileSize;
            Mode          = mode;

            for (int i = 0; i < Sources.Length - 1; i++)
            {
                if (Sources[i].GetSize() != SplitFileSize)
                {
                    throw new ArgumentException($"Source file must have size {splitFileSize}");
                }
            }

            ToDispose.AddRange(Sources);
        }
Beispiel #3
0
        internal ConcatenationFile(IFileSystem baseFileSystem, string path, IEnumerable <IFile> sources, long subFileSize, OpenMode mode)
        {
            BaseFileSystem = baseFileSystem;
            FilePath       = path;
            Sources        = sources.ToList();
            SubFileSize    = subFileSize;
            Mode           = mode;

            for (int i = 0; i < Sources.Count - 1; i++)
            {
                if (Sources[i].GetSize() != SubFileSize)
                {
                    throw new ArgumentException($"Source file must have size {subFileSize}");
                }
            }

            ToDispose.AddRange(Sources);
        }
        public ConcatenationStorage(IList <IStorage> sources, bool leaveOpen)
        {
            Sources = new ConcatSource[sources.Count];
            if (!leaveOpen)
            {
                ToDispose.AddRange(sources);
            }

            long length = 0;

            for (int i = 0; i < sources.Count; i++)
            {
                if (sources[i].Length < 0)
                {
                    throw new ArgumentException("Sources must have an explicit length.");
                }
                Sources[i] = new ConcatSource(sources[i], length, sources[i].Length);
                length    += sources[i].Length;
            }

            Length = length;
        }