Delete a bitstream. This needs more testing - file deletion in a zipfile
        is problematic. Alternate method is to create second zipfile without the files
        in question, which is not a nice method for large zip archives.
191857
def del_stream(self, bucket, label):
        '''
        '''
        if self.exists(bucket, label):
            name = self._zf(bucket, label)
            #z = ZipFile(self.zipfile, self.mode, self.compression, self.allowZip64)
            self._del_stream(name)
1305351
def remove_proxy_zip_if_present():
    
    try:
        if os.path.exists(PROXY_ZIP_PATH):
            os.remove(PROXY_ZIP_PATH)
        elif os.path.exists(PROXY_ZIP_PATH_2):
            os.remove(PROXY_ZIP_PATH_2)
    except Exception:
        pass
197924
def zip(filename, paths, strip_prefix=''):
    
    if isinstance(paths, basestring):
        paths = [paths]

    filelist = set()
    for p in paths:
        if os.path.isfile(p):
            filelist.add(p)
        else:
            for root, dirs, files in os.walk(p):
                for f in files:
                    filelist.add(os.path.join(root, f))

    z = zipfile.ZipFile(filename, 'w', zipfile.ZIP_DEFLATED)
    for f in sorted(filelist):
        arcname = f
        if arcname.startswith(strip_prefix):
            arcname = arcname[len(strip_prefix):]
        if arcname.startswith(os.path.sep):
            arcname = arcname[1:]
        log.debug('Adding %s to %s[%s]', f, filename, arcname)
        z.write(f, arcname)

    z.close()
633562
def delete_archive_file(self):
        
        logger.debug("Deleting %s", self.archive_tmp_dir)
        shutil.rmtree(self.archive_tmp_dir, True)
839716
public static void zipFiles(List<File> files, File zipFile) throws IOException {
        OutputStream os = new BufferedOutputStream(new FileOutputStream(zipFile));
        try {
            zipFiles(files, os);
        } finally {
            IOUtils.closeQuietly(os);
        }
    }
450581
private static void processZipStream(File dir, InputStream inputStream) throws IOException
   {
      ZipInputStream zip = new ZipInputStream(inputStream);
      while (true)
      {
         ZipEntry entry = zip.getNextEntry();
         if (entry == null)
         {
            break;
         }

         File file = new File(dir, entry.getName());
         if (entry.isDirectory())
         {
            FileHelper.mkdirsQuietly(file);
            continue;
         }

         File parent = file.getParentFile();
         if (parent != null)
         {
            FileHelper.mkdirsQuietly(parent);
         }

         FileOutputStream fos = new FileOutputStream(file);
         byte[] bytes = new byte[1024];
         int length;
         while ((length = zip.read(bytes)) >= 0)
         {
            fos.write(bytes, 0, length);
         }
         fos.close();
      }
   }
128936
public function delete($file_name_or_array): ZipManager {

        try {

            foreach ( $this->zip_archives as $archive ) {
                $archive->delete($file_name_or_array);
            }
            return $this;

        } catch (ZipException $ze) {
            throw $ze;
        }

    }
99799
function unZipFile(zipFileName) {
  yauzl.open(zipFileName, {
    lazyEntries: true
  }, function (err, zipFile) {
    if (err) {
      throw err
    }
    zipFile.readEntry()
    zipFile.on('entry', function (entry) {
      if (targetEntry === entry.fileName) {
        mkdirp.sync(writeFolder)
        zipFile.openReadStream(entry, function (errInReadStream, readStream) {
          if (errInReadStream) {
            throw errInReadStream
          }
          readStream.pipe(fs.createWriteStream(binPath))
          readStream.on('end', function () {
            zipFile.readEntry()
            console.log('unzip completed ' + binPath)
            fs.chmodSync(binPath, '755')
            console.log('chmod 755')
          })
        })
      } else {
        zipFile.readEntry()
      }
    })
  })
}
235018
def delete_blob(address)
      unless address >= 0
        PEROBS.log.fatal "Blob address must be larger than 0, " +
          "not #{address}"
      end

      offset = address_to_offset(address)
      begin
        @f.seek(offset)
        if (marker = read_char) != 1 && marker != 2
          PEROBS.log.fatal "Cannot delete blob stored at address #{address} " +
            "of EquiBlobsFile #{@file_name}. Blob is " +
            (marker == 0 ? 'empty' : 'corrupted') + '.'
        end
        @f.seek(address_to_offset(address))
        write_char(0)
        write_unsigned_int(@first_space)
      rescue IOError => e
        PEROBS.log.fatal "Cannot delete blob at address #{address}: " +
          e.message
      end

      @first_space = offset
      @total_spaces += 1
      @total_entries -= 1 unless marker == 1
      write_header

      if offset == @f.size - 1 - @entry_bytes
        # We have deleted the last entry in the file. Make sure that all empty
        # entries are removed up to the now new last used entry.
        trim_file
      end
    end
171038
private void iterateExistingExceptRemoved(ZipEntryOrInfoAdapter zipEntryCallback) {
    if (src == null) {
      // if we don't have source specified, then we have nothing to iterate.
      return;
    }
    final Set<String> removedDirs = ZipUtil.filterDirEntries(src, removedEntries);

    ZipFile zf = null;
    try {
      zf = getZipFile();

      // manage existing entries
      Enumeration<? extends ZipEntry> en = zf.entries();
      while (en.hasMoreElements()) {
        ZipEntry entry = en.nextElement();
        String entryName = entry.getName();
        if (removedEntries.contains(entryName) || isEntryInDir(removedDirs, entryName)) {
          // removed entries are
          continue;
        }

        if (nameMapper != null) {
          String mappedName = nameMapper.map(entry.getName());
          if (mappedName == null) {
            continue; // we should ignore this entry
          }
          else if (!mappedName.equals(entry.getName())) {
            // if name is different, do nothing
            entry = ZipEntryUtil.copy(entry, mappedName);
          }
        }

        InputStream is = zf.getInputStream(entry);
        try {
          zipEntryCallback.process(is, entry);
        }
        catch (ZipBreakException ex) {
          break;
        }
        finally {
          IOUtils.closeQuietly(is);
        }
      }
    }
    catch (IOException e) {
      ZipExceptionUtil.rethrow(e);
    }
    finally {
      ZipUtil.closeQuietly(zf);
    }
  }
245962
def _unpack_zipfile(filename, extract_dir):
    
    try:
        import zipfile
    except ImportError:
        raise ReadError('zlib not supported, cannot unpack this archive.')

    if not zipfile.is_zipfile(filename):
        raise ReadError("%s is not a zip file" % filename)

    zip = zipfile.ZipFile(filename)
    try:
        for info in zip.infolist():
            name = info.filename

            # don't extract absolute paths or ones with .. in them
            if name.startswith('/') or '..' in name:
                continue

            target = os.path.join(extract_dir, *name.split('/'))
            if not target:
                continue

            _ensure_directory(target)
            if not name.endswith('/'):
                # file
                data = zip.read(info.filename)
                f = open(target, 'wb')
                try:
                    f.write(data)
                finally:
                    f.close()
                    del data
    finally:
        zip.close()
1018199
public static void unZip(File inFile, File unzipDir) throws IOException {
    Enumeration<? extends ZipEntry> entries;
    ZipFile zipFile = new ZipFile(inFile);

    try {
      entries = zipFile.entries();
      while (entries.hasMoreElements()) {
        ZipEntry entry = entries.nextElement();
        if (!entry.isDirectory()) {
          InputStream in = zipFile.getInputStream(entry);
          try {
            File file = new File(unzipDir, entry.getName());
            if (!file.getParentFile().mkdirs()) {
              if (!file.getParentFile().isDirectory()) {
                throw new IOException("Mkdirs failed to create " +
                                      file.getParentFile().toString());
              }
            }
            OutputStream out = new FileOutputStream(file);
            try {
              byte[] buffer = new byte[8192];
              int i;
              while ((i = in.read(buffer)) != -1) {
                out.write(buffer, 0, i);
              }
            } finally {
              out.close();
            }
          } finally {
            in.close();
          }
        }
      }
    } finally {
      zipFile.close();
    }
  }
1043818
def WriteFileChunk(self, chunk):
    """"""
    precondition.AssertType(chunk, bytes)

    if not self._stream:
      raise ArchiveAlreadyClosedError(
          "Attempting to write to a ZIP archive that was already closed.")

    self.cur_file_size += len(chunk)
    # TODO(user):pytype: crc32 is not visible outside of zipfile.
    # pytype: disable=module-attr
    self.cur_crc = zipfile.crc32(chunk, self.cur_crc) & 0xffffffff
    # pytype: enable=module-attr

    if self.cur_cmpr:
      chunk = self.cur_cmpr.compress(chunk)
      self.cur_compress_size += len(chunk)

    self._stream.write(chunk)
    return self._stream.GetValueAndReset()
155417
def delete
      unless in_zip?
        FileUtils.rm_rf selected_items.map(&:path)
      else
        Zip::File.open(current_zip) do |zip|
          zip.select {|e| selected_items.map(&:name).include? e.to_s}.each do |entry|
            if entry.name_is_directory?
              zip.dir.delete entry.to_s
            else
              zip.file.delete entry.to_s
            end
          end
        end
      end
      @current_row -= selected_items.count {|i| i.index <= current_row}
      ls
    end
1334168
function zipDirectory(directories, dest, callback) {
        var archive = archiver.create('zip', {gzip: false});

        // Where to write the file
        var destStream = fs.createWriteStream(dest);

        archive.on('error', function(err) {
            this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Archiving failed', err));
        });

        archive.on('entry', function(file) {
            // do nothing
        });

        destStream.on('error', function(err) {
            this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'WriteStream failed', err));
        });

        destStream.on('close', function() {
            var size = archive.pointer();
            gutil.log(PLUGIN_NAME, gutil.colors.green('Created ' + dest + ' (' + size + ' bytes)'));
            callback();
        });

        archive.pipe(destStream);

        directories.forEach(function(directory) {
            if (fs.lstatSync(directory.src).isDirectory()) {
              archive.directory(directory.src, directory.dest);
            } else {
              this.emit('error', new gutil.PluginError(PLUGIN_NAME, directory.src + ' is not a valid directory'));
              return;
            }
        });

        archive.finalize();
    }
368695
public static void removeEntries(File zip, String[] paths, File destZip) {
    if (log.isDebugEnabled()) {
      log.debug("Copying '" + zip + "' to '" + destZip + "' and removing paths " + Arrays.asList(paths) + ".");
    }

    ZipOutputStream out = null;
    try {
      out = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(destZip)));
      copyEntries(zip, out, new HashSet<String>(Arrays.asList(paths)));
    }
    catch (IOException e) {
      throw ZipExceptionUtil.rethrow(e);
    }
    finally {
      IOUtils.closeQuietly(out);
    }
  }
420903
function zip_send_bits(
  value,	// value to send
  length) {	// number of bits
  /* If not enough room in bi_buf, use (valid) bits from bi_buf and
   * (16 - bi_valid) bits from value, leaving (width - (16-bi_valid))
   * unused bits in value.
   */
  if (zip_bi_valid > zip_Buf_size - length) {
    zip_bi_buf |= (value << zip_bi_valid);
    zip_put_short(zip_bi_buf);
    zip_bi_buf = (value >> (zip_Buf_size - zip_bi_valid));
    zip_bi_valid += length - zip_Buf_size;
  } else {
    zip_bi_buf |= value << zip_bi_valid;
    zip_bi_valid += length;
  }
}