diff options
author | 2015-07-09 17:45:13 +0000 | |
---|---|---|
committer | 2015-07-10 17:19:09 +0000 | |
commit | db0b68de9e973a81848f49294485d7e8b6f5ec39 (patch) | |
tree | 63558a1ea9ff6e722994697f75e15d55b2c77984 /src/tools/xcode-common/java/com/google | |
parent | 491ed5e57521407b03e01a9e097c7dbd8272ff12 (diff) |
Allows bundlemerge to handle zip files that have directory entries in them. Directory entries are allowed to exist in multiple zip files. File entries are only allowed to exist in one zip file.
RELNOTES:None
--
MOS_MIGRATED_REVID=97887821
Diffstat (limited to 'src/tools/xcode-common/java/com/google')
-rw-r--r-- | src/tools/xcode-common/java/com/google/devtools/build/xcode/zip/ZipInputEntry.java | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zip/ZipInputEntry.java b/src/tools/xcode-common/java/com/google/devtools/build/xcode/zip/ZipInputEntry.java index 0621716576..e6272ce7be 100644 --- a/src/tools/xcode-common/java/com/google/devtools/build/xcode/zip/ZipInputEntry.java +++ b/src/tools/xcode-common/java/com/google/devtools/build/xcode/zip/ZipInputEntry.java @@ -92,11 +92,20 @@ public class ZipInputEntry extends Value<ZipInputEntry> { } /** - * Adds this entry to a zip using the given {@code ZipCombiner}. + * Adds this entry to a zip using the given {@code ZipCombiner}. Entry can be either a directory + * or a file. */ public void add(ZipCombiner combiner) throws IOException { + ZipFileEntry entry = new ZipFileEntry(zipPath); + if (Files.isDirectory(source)) { + String name = entry.getName(); + if (!name.endsWith("/")) { + name = name + "/"; + } + combiner.addDirectory(name, DOS_EPOCH); + return; + } try (InputStream inputStream = Files.newInputStream(source)) { - ZipFileEntry entry = new ZipFileEntry(zipPath); entry.setTime(DOS_EPOCH.getTime()); entry.setVersion(MADE_BY_VERSION); entry.setExternalAttributes(externalFileAttribute); @@ -125,6 +134,7 @@ public class ZipInputEntry extends Value<ZipInputEntry> { * <li>bar/c * <li>baz/d * </ul> + * Note that currently this doesn't add directory entries. */ public static Iterable<ZipInputEntry> fromDirectory(final Path rootDirectory) throws IOException { final ImmutableList.Builder<ZipInputEntry> zipInputs = new ImmutableList.Builder<>(); |