fix: normalize path to fix building .apk on Windows

- fixes #1741
This commit is contained in:
Connor Tumbleson 2018-04-05 16:24:58 -04:00
parent e679d71615
commit 07afbdb52b
2 changed files with 12 additions and 1 deletions

View File

@ -54,7 +54,8 @@ public class ZipUtils {
throws BrutException, IOException {
for (final File file : folder.listFiles()) {
if (file.isFile()) {
final ZipEntry zipEntry = new ZipEntry(BrutIO.sanitizeUnknownFile(folder, file.getPath().substring(prefixLength)));
final String normalizedPath = BrutIO.normalizePath(file.getPath().substring(prefixLength));
final ZipEntry zipEntry = new ZipEntry(BrutIO.sanitizeUnknownFile(folder, normalizedPath));
// aapt binary by default takes in parameters via -0 arsc to list extensions that shouldn't be
// compressed. We will replicate that behavior

View File

@ -97,6 +97,16 @@ public class BrutIO {
return canonicalEntryPath.substring(canonicalDirPath.length());
}
public static String normalizePath(String path) {
char separator = File.separatorChar;
if (separator != '/') {
return path.replace(separator, '/');
}
return path;
}
public static void copy(File inputFile, ZipOutputStream outputFile) throws IOException {
try (
FileInputStream fis = new FileInputStream(inputFile)