Beispiel #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();
            }
        }
Beispiel #2
0
 public TarArchive(Stream stream, TarArchiveMode mode, bool leaveOpen)
     : this(stream, mode, stream.CanSeek ? StreamAccessMode.Random : StreamAccessMode.Sequential, leaveOpen)
 {
 }
Beispiel #3
0
 public TarArchive(Stream stream, TarArchiveMode mode)
     : this(stream, mode, false)
 {
 }