[libbluray-devel] BD-J: resolve relative paths to Xlet home directory

hpi1 git at videolan.org
Fri Nov 7 14:37:38 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Nov  7 15:36:47 2014 +0200| [094eb2f92381c158a9c4c3261e721c4657bbe672] | committer: hpi1

BD-J: resolve relative paths to Xlet home directory

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

 src/libbluray/bdj/java/java/io/BDFileSystem.java |   23 +++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/src/libbluray/bdj/java/java/io/BDFileSystem.java b/src/libbluray/bdj/java/java/io/BDFileSystem.java
index 39478e2..64c2f69 100644
--- a/src/libbluray/bdj/java/java/io/BDFileSystem.java
+++ b/src/libbluray/bdj/java/java/io/BDFileSystem.java
@@ -85,7 +85,27 @@ public abstract class BDFileSystem extends FileSystem {
         return fs.prefixLength(pathname);
     }
 
+    private boolean isAbsolutePath(String path) {
+        return path.startsWith("/") || path.indexOf(":\\") == 1 ||
+            path.startsWith("\\");
+    }
+
+    private String getHomeDir() {
+        String home = BDJXletContext.getCurrentXletHome();
+        if (home == null)
+            return "";
+        return home;
+    }
+
     public String resolve(String parent, String child) {
+        if (parent == null || parent.equals("") || parent.equals(".")) {
+            parent = getHomeDir();
+        }
+        else if (!isAbsolutePath(parent)) {
+            logger.info("resolve relative file at " + parent);
+            parent = getHomeDir() + parent;
+        }
+
         String resolvedPath = fs.resolve(parent, child);
         String cachePath = BDJLoader.getCachedFile(resolvedPath);
         if (cachePath != resolvedPath) {
@@ -108,7 +128,8 @@ public abstract class BDFileSystem extends FileSystem {
 
     public String resolve(File f) {
         if (!f.isAbsolute()) {
-            System.err.println("***** resolve " + f + " -> " + fs.resolve(f));
+            logger.info("resolve relative file " + f.getPath());
+            return resolve(BDJXletContext.getCurrentXletHome(), f.getPath());
         }
 
         String resolvedPath = fs.resolve(f);



More information about the libbluray-devel mailing list