[libbluray-devel] Improve readability

hpi1 git at videolan.org
Thu Jul 6 23:23:43 CEST 2017


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Jun 16 00:40:19 2017 +0300| [02d1d21163bae21f94f69024d8b5073fa239974d] | committer: hpi1

Improve readability

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

 .../bdj/java/org/videolan/BDJClassLoader.java      | 51 ++++++++++++++--------
 1 file changed, 33 insertions(+), 18 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/BDJClassLoader.java b/src/libbluray/bdj/java/org/videolan/BDJClassLoader.java
index 27c3d9a1..0eccd30d 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJClassLoader.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJClassLoader.java
@@ -59,28 +59,43 @@ public class BDJClassLoader extends URLClassLoader {
             path = basePath + "/" + classPath;
         if (path.length() < 5)
             return null;
-        String protocol = null;
-        String url = path.substring(0, 5);
-        for (int i = 0; i < appCaches.length; i++) {
-            if (appCaches[i].getRefToName().equals(url)) {
-                if (appCaches[i].getType() == AppCache.JAR_FILE) {
-                    protocol = "file:";
-                    url = url + ".jar";
-                } else if (appCaches[i].getType() == AppCache.DIRECTORY) {
-                    protocol = "file:/";
-                }
+
+        String name = path.substring(0, 5); /* entry name in BDMV/JAR/ */
+        String dir  = path.substring(5);    /* optional sub directory */
+
+        /* find bdjo AppCache entry */
+        int i;
+        for (i = 0; i < appCaches.length; i++) {
+            if (appCaches[i].getRefToName().equals(name)) {
                 break;
             }
         }
-        if (protocol == null)
+        if (i >= appCaches.length)
+            return null;
+
+        /* check AppCache type */
+        String protocol;
+        if (appCaches[i].getType() == AppCache.JAR_FILE) {
+            protocol = "file:";
+            name = name + ".jar";
+        } else if (appCaches[i].getType() == AppCache.DIRECTORY) {
+            protocol = "file:/";
+        } else {
             return null;
-        url = protocol +
-            BDJLoader.getCachedFile(System.getProperty("bluray.vfs.root") + File.separator +
-                                    "BDMV" + File.separator +
-                                    "JAR" + File.separator +
-                                    url) + path.substring(5);
-        //if (!url.endsWith("/"))
-        //    url += "/";
+        }
+
+        /* map to disc root */
+        String fullPath =
+            System.getProperty("bluray.vfs.root") + File.separator +
+            "BDMV" + File.separator + "JAR" + File.separator +
+            name;
+
+        /* find from cache */
+        String cachePath = BDJLoader.getCachedFile(fullPath);
+
+        /* build final url */
+        String url = protocol + cachePath + dir;
+
         try {
             return new URL(url);
         } catch (MalformedURLException e) {



More information about the libbluray-devel mailing list