[libbluray-devel] BDJ: canonicalize storage paths

hpi1 git at videolan.org
Fri Mar 6 08:54:10 CET 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Mar  5 12:37:51 2015 +0200| [f55cb2ab6ac133745e328bdb5f0431ad68d18343] | committer: hpi1

BDJ: canonicalize storage paths

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=f55cb2ab6ac133745e328bdb5f0431ad68d18343
---

 src/libbluray/bdj/java/org/videolan/Libbluray.java |   21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index 231eae5..7222b05 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -48,17 +48,32 @@ import org.videolan.media.content.PlayerManager;
  */
 public class Libbluray {
 
+    private static String canonicalize(String path, boolean create) {
+        try {
+            File dir = new File(path);
+            if (create) {
+                dir.mkdirs();
+            }
+            return dir.getCanonicalPath();
+        } catch (Exception ioe) {
+            System.err.println("error canonicalizing " + path + ": " + ioe);
+        }
+        return path;
+    }
+
     /* called only from native code */
     private static void init(long nativePointer, String discID, String discRoot,
                                String persistentRoot, String budaRoot) {
 
+        /* set up directories */
+        persistentRoot = canonicalize(persistentRoot, true);
+        budaRoot       = canonicalize(budaRoot, true);
+
         System.setProperty("dvb.persistent.root", persistentRoot);
         System.setProperty("bluray.bindingunit.root", budaRoot);
 
-        new File(persistentRoot).mkdirs();
-        new File(budaRoot).mkdirs();
-
         if (discRoot != null) {
+            discRoot = canonicalize(discRoot, false);
             System.setProperty("bluray.vfs.root", discRoot);
         } else {
             System.getProperties().remove("bluray.vfs.root");



More information about the libbluray-devel mailing list