Beispiel #1
0
        public static IStorage Slice(this IStorage storage, long start)
        {
            long length = storage.GetSize();

            if (length == -1)
            {
                return(storage.Slice(start, length));
            }

            return(storage.Slice(start, length - start));
        }
        private static List <IStorage> ToStorageList(IvfcHeader header, IStorage masterHash, IStorage data, bool leaveOpen)
        {
            var levels = new List <IStorage> {
                masterHash
            };

            for (int i = 0; i < header.NumLevels - 1; i++)
            {
                IvfcLevelHeader level = header.LevelHeaders[i];
                levels.Add(data.Slice(level.Offset, level.Size, leaveOpen));
            }

            return(levels);
        }
Beispiel #3
0
        public IStorage GetPatchedStorage()
        {
            if (Original == null)
            {
                throw new InvalidOperationException("Cannot apply a delta patch without a base file.");
            }

            var storages = new List <IStorage>();

            foreach (DeltaFragmentSegment segment in Segments)
            {
                IStorage source = segment.IsInOriginal ? Original : Delta;

                // todo Do this without tons of SubStorages
                IStorage sub = source.Slice(segment.SourceOffset, segment.Size);

                storages.Add(sub);
            }

            return(new ConcatenationStorage(storages, true));
        }
Beispiel #4
0
 public static IStorage Slice(this IStorage storage, long start, long length)
 {
     return(storage.Slice(start, length, true));
 }