예제 #1
0
        public TarArchive(Stream stream, TarArchiveMode mode, StreamAccessMode access, bool leaveOpen)
        {
            this.baseStream  = stream;
            this.ArchiveMode = mode;
            this.AccessMode  = access;
            this.leaveOpen   = leaveOpen;

            if (access == StreamAccessMode.Random)
            {
                if (!stream.CanSeek)
                {
                    throw new StreamAccessException("The given stream does not support random access.");
                }
                else
                {
                    this.RandomAccess = new TarIOBlockManager(this, baseStream);
                }
            }
            else if (access == StreamAccessMode.Sequential)
            {
                SequentialAccess = new TarSequentialCollection(this, stream);
            }
            else
            {
                throw new NotImplementedException("Unknown access type");
            }


            if (mode == TarArchiveMode.Read || mode == TarArchiveMode.Update)
            {
                this.ParseFile();
            }
        }
예제 #2
0
 public TarEntryEnumerator(TarSequentialCollection entries)
 {
     this.entries = entries;
     this.reader  = new BinaryReader(entries.BaseStream, Encoding.ASCII, true);
 }