Skip to content

Commit

Permalink
Have zipper use standard-compliant path separators
Browse files Browse the repository at this point in the history
  • Loading branch information
cxcorp committed Jan 3, 2017
1 parent fce2329 commit da52b9a
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -110,10 +111,13 @@ private void writeToZip(Path currentPath, ZipArchiveOutputStream zipStream, Path
log.trace("Writing {} to zip", currentPath);

String name = projectPath.getParent().relativize(currentPath).toString();
// zip standard says "/" is to be used as the path separator
name = FilenameUtils.separatorsToUnix(name);

if (Files.isDirectory(currentPath)) {
log.trace("{} is a directory", currentPath);
// Must be "/", can not be replaces with File.separator
// ZipArchiveEntry assumes the entry represents a directory if and only
// if the name ends with a forward slash "/".
name += "/";
}

Expand Down

0 comments on commit da52b9a

Please sign in to comment.