dsmiley commented on code in PR #732:
URL: https://github.com/apache/commons-io/pull/732#discussion_r2028731835


##########
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:
   Hmm.  In my (limited) experience looking at Path with say mac/unix, there's 
never a trailing slash in path.toString().  (Maybe I could be wrong).   Maybe 
this isn't universally true... which sucks because Path is supposed to be an 
abstraction



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to