xintongsong commented on code in PR #21125:
URL: https://github.com/apache/flink/pull/21125#discussion_r1007846839


##########
flink-core/src/main/java/org/apache/flink/util/FileUtils.java:
##########
@@ -648,6 +648,29 @@ public static String stripFileExtension(String fileName) {
         return fileName;
     }
 
+    /**
+     * Get a target path(the path that replaced symbolic links with linked 
path) if the original
+     * path contains symbolic path, return the original path otherwise.
+     *
+     * @param path the original path.
+     * @return the path that replaced symbolic links with real path.
+     */
+    public static java.nio.file.Path 
getTargetPathIfContainsSymbolicPath(java.nio.file.Path path)
+            throws IOException {
+        java.nio.file.Path targetPath = path;
+        java.nio.file.Path suffixPath = Paths.get("");
+        while (path != null && path.getFileName() != null) {
+            if (Files.isSymbolicLink(path)) {
+                java.nio.file.Path linkedPath = path.toRealPath();
+                targetPath = Paths.get(linkedPath.toString(), 
suffixPath.toString());
+                break;

Review Comment:
   What happens if there're multiple symbolic links in the path?



-- 
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...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to