Skip to content

Commit

Permalink
#440 Replace Windows file separator with zip separator
Browse files Browse the repository at this point in the history
  • Loading branch information
srikanth-lingala committed Jun 23, 2022
1 parent 723a716 commit 7b586be
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.regex.Matcher;

import static net.lingala.zip4j.util.InternalZipConstants.FILE_SEPARATOR;

Expand Down Expand Up @@ -173,7 +174,12 @@ private File determineOutputFile(FileHeader fileHeader, String outputPath, Strin
if (Zip4jUtil.isStringNotNullAndNotEmpty(newFileName)) {
outputFileName = newFileName;
}
return new File(outputPath + FILE_SEPARATOR + outputFileName);
return new File(outputPath, getFileNameWithSystemFileSeparators(outputFileName));
}

private String getFileNameWithSystemFileSeparators(String fileNameToReplace) {
String formattedFileName = fileNameToReplace.replaceAll(":\\\\", "_");
return formattedFileName.replaceAll("[/\\\\]", Matcher.quoteReplacement(FILE_SEPARATOR));
}

@Override
Expand Down

0 comments on commit 7b586be

Please sign in to comment.