sid-srini commented on code in PR #7722:
URL: https://github.com/apache/netbeans/pull/7722#discussion_r1743582406


##########
ide/projectapi/src/org/netbeans/modules/projectapi/SimpleFileOwnerQueryImplementation.java:
##########
@@ -414,6 +421,18 @@ private static URI goUp(URI u) {
         assert u.toString().startsWith(nue.toString()) : "not a parent: " + 
nue + " of " + u;
         return nue;
     }
+
+    private static Set<String> extractFolderPaths(String folders, String 
pathSeparator) {
+        Set<String> paths = Arrays.stream(folders.split(pathSeparator))   
//NOI18N
+                .filter(s -> !s.trim().isEmpty())
+                .map(f -> FileUtil.toFileObject(FileUtil.normalizeFile(new 
File(f))))

Review Comment:
   The `FileObject` is needed because the comparison in `getOwner()` is done 
with a `FileObject.getPath()` string.
   The latter does have some peculiarities as compared to 
`File.getAbsolutePath()` and hence I could not assume that the implementation 
would always give a comparable result.
   - For example: `FileUtil.toFileObject(new File("/")).getPath() == ""`
   
   
   The `FileUtil.normalizeFile()` is needed in order to ensure that variations 
in terms of ".." or "." or windows drive-letter case differences are ironed out 
before comparison.
   - This may be better than using `File.getCanonicalPath()` since it doesn't 
resolve symlinks.
   
   This round-trip also helps to get rid of non-existent or invalid paths, that 
would otherwise cause inefficiency or errors.
   
   There is a performance cost of this, but since it is only at the time of 
initialisation, and not every invocation of `getOwner()`, the reliability 
benefits seem to outweigh the cost.



-- 
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]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to