diff --git a/src/main/java/org/zeroturnaround/zip/commons/FileUtilsV2_2.java b/src/main/java/org/zeroturnaround/zip/commons/FileUtilsV2_2.java index 8fb5292..a589817 100644 --- a/src/main/java/org/zeroturnaround/zip/commons/FileUtilsV2_2.java +++ b/src/main/java/org/zeroturnaround/zip/commons/FileUtilsV2_2.java @@ -576,7 +576,7 @@ public static void copyDirectory(File srcDir, File destDir, // Cater for destination being directory within the source directory (see IO-141) List exclusionList = null; - if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) { + if (destDir.getCanonicalFile().toPath().startsWith(srcDir.getCanonicalFile().toPath())) { File[] srcFiles = filter == null ? srcDir.listFiles() : srcDir.listFiles(filter); if (srcFiles != null && srcFiles.length > 0) { exclusionList = new ArrayList(srcFiles.length); @@ -997,7 +997,7 @@ public static void moveDirectory(File srcDir, File destDir) throws IOException { } boolean rename = srcDir.renameTo(destDir); if (!rename) { - if (destDir.getCanonicalPath().startsWith(srcDir.getCanonicalPath())) { + if (destDir.getCanonicalFile().toPath().startsWith(srcDir.getCanonicalFile().toPath())) { throw new IOException("Cannot move directory: "+srcDir+" to a subdirectory of itself: "+destDir); } copyDirectory( srcDir, destDir );