garydgregory commented on code in PR #732: URL: https://github.com/apache/commons-io/pull/732#discussion_r2027707297
########## src/main/java/org/apache/commons/io/file/PathUtils.java: ########## @@ -148,6 +148,51 @@ private RelativeSortedPaths(final Path dir1, final Path dir2, final int maxDepth relativeFileList1 = tmpRelativeFileList1; relativeFileList2 = tmpRelativeFileList2; } + + /** + * Compare Path lists in a FileSystem agnostic way + * + * @param a first list + * @param b second list + * @return true if the lists are equal + */ + private boolean equals(List<Path> a, List<Path> b) { + if (a.size() != b.size()) { + return false; + } + // compare both lists using iterators + final Iterator<Path> listAIter = a.iterator(); + final Iterator<Path> listBIter = b.iterator(); + while (listAIter.hasNext() && listBIter.hasNext()) { + final Path pathA = listAIter.next(); + final Path pathB = listBIter.next(); + if (pathA.getFileSystem() == pathB.getFileSystem()) { + if (!pathA.equals(pathB)) { + return false; + } + } else if (pathA.getFileSystem().getSeparator().equals(pathB.getFileSystem().getSeparator())) { + // Separators are the same, so we can use toString comparison + if (!pathA.toString().equals(pathB.toString())) { + return false; Review Comment: Hm, the binary search in `directoryAndFileContentEquals` will also need a custom comparator or you get a `ProviderMismatchException` like: ``` java.nio.file.ProviderMismatchException at com.sun.nio.zipfs.ZipPath.checkPath(ZipPath.java:393) at com.sun.nio.zipfs.ZipPath.compareTo(ZipPath.java:620) at com.sun.nio.zipfs.ZipPath.compareTo(ZipPath.java:59) at java.util.Collections.indexedBinarySearch(Collections.java:228) at java.util.Collections.binarySearch(Collections.java:215) at org.apache.commons.io.file.PathUtils.directoryAndFileContentEquals(PathUtils.java:711) at org.apache.commons.io.file.PathUtils.directoryAndFileContentEquals(PathUtils.java:675) at org.apache.commons.io.file.PathUtilsContentEqualsTest.testDirectoryAndFileContentEqualsDifferentFileSystems(PathUtilsContentEqualsTest.java:115) at java.lang.reflect.Method.invoke(Method.java:503) at java.util.ArrayList.forEach(ArrayList.java:1259) at java.util.ArrayList.forEach(ArrayList.java:1259) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@commons.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org