Esempio n. 1
0
        private Stream OpenInReadMode()
        {
            var bigStream = new BigArchiveEntryStream(this, Offset);

            // Wrapping BigStream in a BufferedStream significantly improves performance.
            var bufferedBigStream = new BufferedStream(bigStream);

            // Check for refpack compression header.
            // C&C3 started using refpack compression for .big archive entries.
            if (RefPackStream.IsProbablyRefPackCompressed(bufferedBigStream))
            {
                var refPackStream = new RefPackStream(bufferedBigStream);

                // Wrap RefPackStream in (another) BufferedStream, to improve performance.
                return(new BufferedStream(refPackStream));
            }

            return(bufferedBigStream);
        }
Esempio n. 2
0
        private Stream OpenInWriteMode()
        {
            if (CurrentlyOpenForWrite)
            {
                throw new IOException("Can only write once and one entry at a time!");
            }

            CurrentlyOpenForWrite = true;

            var bigStream = new BigArchiveEntryStream(this, Offset);

            // Check for refpack compression header.
            // C&C3 started using refpack compression for .big archive entries.
            if (RefPackStream.IsProbablyRefPackCompressed(bigStream))
            {
                return(new RefPackStream(bigStream));
            }

            return(bigStream);
        }