Skip to content

Commit

Permalink
Have zipper use standard-compliant path separators
Browse files Browse the repository at this point in the history
Closes #75
  • Loading branch information
cxcorp committed Dec 22, 2016
1 parent fce2329 commit c04726f
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.FileUtils;

import org.slf4j.Logger;
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 c04726f

Please sign in to comment.