Exemplo n.º 1
0
        public void AddStream(
            BlueStacks.BlueStacksUI.Compression _method,
            string _filenameInZip,
            Stream _source,
            DateTime _modTime,
            string _comment)
        {
            if (this.Access == FileAccess.Read || _source == null || string.IsNullOrEmpty(_filenameInZip))
            {
                throw new InvalidOperationException("Writing is not alowed");
            }
            ZipFileEntry _zfe = new ZipFileEntry()
            {
                Method        = _method,
                EncodeUTF8    = this.EncodeUTF8,
                FilenameInZip = ZipStorer.NormalizedFilename(_filenameInZip),
                Comment       = _comment ?? "",
                Crc32         = 0,
                HeaderOffset  = (uint)this.ZipFileStream.Position,
                ModifyTime    = _modTime
            };

            this.WriteLocalHeader(ref _zfe);
            _zfe.FileOffset = (uint)this.ZipFileStream.Position;
            this.Store(ref _zfe, _source);
            _source.Close();
            this.UpdateCrcAndSizes(ref _zfe);
            this.Files.Add(_zfe);
        }
Exemplo n.º 2
0
        public void AddFile(
            BlueStacks.BlueStacksUI.Compression _method,
            string _pathname,
            string _filenameInZip,
            string _comment)
        {
            if (this.Access == FileAccess.Read)
            {
                throw new InvalidOperationException("Writing is not alowed");
            }
            FileStream fileStream = new FileStream(_pathname, FileMode.Open, FileAccess.Read);

            this.AddStream(_method, _filenameInZip, (Stream)fileStream, File.GetLastWriteTime(_pathname), _comment);
            fileStream.Close();
        }