From c04726f8f2b5cdde0c4bf876f97c226a51ecfae4 Mon Sep 17 00:00:00 2001 From: cxcorp Date: Thu, 22 Dec 2016 16:55:57 +0200 Subject: [PATCH] Have zipper use standard-compliant path separators Closes #75 --- .../cs/tmc/langs/io/zip/StudentFileAwareZipper.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tmc-langs-framework/src/main/java/fi/helsinki/cs/tmc/langs/io/zip/StudentFileAwareZipper.java b/tmc-langs-framework/src/main/java/fi/helsinki/cs/tmc/langs/io/zip/StudentFileAwareZipper.java index 916ae756b..14c0ec678 100644 --- a/tmc-langs-framework/src/main/java/fi/helsinki/cs/tmc/langs/io/zip/StudentFileAwareZipper.java +++ b/tmc-langs-framework/src/main/java/fi/helsinki/cs/tmc/langs/io/zip/StudentFileAwareZipper.java @@ -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; @@ -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 += "/"; }