コード例 #1
0
        public Stream Open()
        {
            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);
        }
コード例 #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);
        }
コード例 #3
0
        public Stream Open()
        {
            // TODO: Use System.IO.MemoryMappedFiles
            using (var bigStream = new BigStream(this, _offset))
            {
                var result = new MemoryStream((int)Length);

                bigStream.CopyTo(result);

                result.Position = 0;

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

                return(result);
            }
        }