Search in sources :

Example 1 with ExtraDataList

use of com.google.devtools.build.zip.ExtraDataList in project bazel by bazelbuild.

the class ZipCombiner method addDirectory.

/**
   * Adds a directory entry to the combined ZIP file using the specified filename, date, and extra
   * data.
   *
   * @param filename the name of the directory to create
   * @param date the modified time to assign to the directory
   * @param extra the extra field data to add to the directory entry
   * @throws IOException if there is an error writing the directory entry
   */
public void addDirectory(String filename, Date date, ExtraData[] extra) throws IOException {
    checkArgument(filename.endsWith("/"), "Directory names must end with a /");
    checkState(!entries.containsKey(filename), "Zip already contains a directory named %s", filename);
    ZipFileEntry entry = new ZipFileEntry(filename);
    entry.setMethod(Compression.STORED);
    entry.setCrc(0);
    entry.setSize(0);
    entry.setCompressedSize(0);
    entry.setTime(date != null ? date.getTime() : new Date().getTime());
    entry.setExtra(new ExtraDataList(extra));
    out.putNextEntry(entry);
    out.closeEntry();
    entries.put(filename, entry);
}
Also used : ZipFileEntry(com.google.devtools.build.zip.ZipFileEntry) ExtraDataList(com.google.devtools.build.zip.ExtraDataList) Date(java.util.Date)

Aggregations

ExtraDataList (com.google.devtools.build.zip.ExtraDataList)1 ZipFileEntry (com.google.devtools.build.zip.ZipFileEntry)1 Date (java.util.Date)1