Ejemplo n.º 1
0
        public Stream RecreateListing(int newSize)
        {
            try
            {
                if (_level == 0)
                {
                    return(_listingFile.RecreateFile());
                }

                long capacity = MathEx.RoundUp(ListingEntry.Size, 0x800);
                if (newSize <= capacity)
                {
                    return(_listingFile.CreateViewStream(ListingEntry.Offset, newSize, MemoryMappedFileAccess.Write));
                }

                long   offset;
                Stream result = _listingFile.IncreaseSize(MathEx.RoundUp(newSize, 0x800), out offset);
                ListingEntry.Sector = (int)(offset / 0x800);
                return(result);
            }
            finally
            {
                ListingEntry.Size             = newSize;
                ListingEntry.UncompressedSize = newSize;
            }
        }
Ejemplo n.º 2
0
        public Stream OpenOrAppendBinary(ArchiveEntry entry, int newSize)
        {
            try
            {
                long capacity = MathEx.RoundUp(entry.Size, 0x800);
                if (newSize <= capacity)
                {
                    return(_binaryFile.CreateViewStream(entry.Offset, newSize, MemoryMappedFileAccess.Write));
                }

                long   offset;
                Stream result = _binaryFile.IncreaseSize(MathEx.RoundUp(newSize, 0x800), out offset);
                entry.Sector = (int)(offset / 0x800);
                return(result);
            }
            finally
            {
                entry.Size = newSize;
            }
        }