[libbluray-devel] MountManager: allow mounting without class files

hpi1 git at videolan.org
Wed Nov 5 12:46:33 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Nov  5 13:45:44 2014 +0200| [88224ee1e362ced67a4bedd61805a74b36dca93d] | committer: hpi1

MountManager: allow mounting without class files

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

 .../bdj/java/org/videolan/MountManager.java        |   47 +++++++++++++++++---
 1 file changed, 40 insertions(+), 7 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/MountManager.java b/src/libbluray/bdj/java/org/videolan/MountManager.java
index 696f6db..91bdc41 100644
--- a/src/libbluray/bdj/java/org/videolan/MountManager.java
+++ b/src/libbluray/bdj/java/org/videolan/MountManager.java
@@ -42,6 +42,10 @@ import java.util.jar.JarFile;
 public class MountManager {
 
     public static String mount(int jarId) throws MountException {
+        return mount(jarId, true);
+    }
+
+    protected static String mount(int jarId, boolean classFiles) throws MountException {
         String jarStr = jarIdToString(jarId);
 
         logger.info("Mounting JAR: " + jarStr);
@@ -56,7 +60,12 @@ public class MountManager {
             if (mountPoint != null) {
                 logger.info("JAR " + jarId + " already mounted");
                 mountPoint.incRefCount();
-                return mountPoint.getMountPoint();
+
+                if (classFiles && !mountPoint.classFiles()) {
+                    logger.info("JAR " + jarId + " not complete, remounting");
+                } else {
+                    return mountPoint.getMountPoint();
+                }
             }
 
         String path = System.getProperty("bluray.vfs.root") + "/BDMV/JAR/" + jarStr + ".jar";
@@ -64,7 +73,9 @@ public class MountManager {
         JarFile jar = null;
         try {
             jar = new JarFile(path);
-            mountPoint = new MountPoint(jarStr);
+            if (mountPoint == null) {
+                mountPoint = new MountPoint(jarStr, classFiles);
+            }
         } catch (IOException e) {
             e.printStackTrace();
             throw new MountException();
@@ -77,14 +88,16 @@ public class MountManager {
                 JarEntry entry = (JarEntry)entries.nextElement();
                 File out = new File(mountPoint.getMountPoint() + File.separator + entry.getName());
 
-                logger.info("   mount: " + entry.getName());
-
                 if (entry.isDirectory()) {
                     out.mkdirs();
+                } else if (!classFiles && entry.getName().endsWith(".class")) {
+                    //logger.info("skip " + entry.getName());
                 } else {
                     /* make sure path exists */
                     out.getParentFile().mkdirs();
 
+                    logger.info("   mount: " + entry.getName());
+
                     InputStream inStream = jar.getInputStream(entry);
                     OutputStream outStream = new FileOutputStream(out);
 
@@ -103,9 +116,20 @@ public class MountManager {
             throw new MountException();
         }
 
-        logger.info("Mounting JAR " + jarId + " complete.");
+        if (mountPoint.classFiles() != classFiles) {
+            if (mountPoint.classFiles()) {
+                logger.error("assertion failed");
+            } else {
+                logger.info("Remounting FULL JAR " + jarId + " complete.");
+                mountPoint.setClassFiles();
+            }
+        } else {
+            logger.info("Mounting " + (classFiles ? "FULL" : "PARTIAL") +
+                        " JAR " + jarId + " complete.");
+
+            mountPoints.put(new Integer(jarId), mountPoint);
+        }
 
-        mountPoints.put(new Integer(jarId), mountPoint);
         return mountPoint.getMountPoint();
         }
     }
@@ -170,9 +194,10 @@ public class MountManager {
     private static final Logger logger = Logger.getLogger(MountManager.class.getName());
 
     private static class MountPoint {
-        public MountPoint(String id) throws IOException {
+        public MountPoint(String id, boolean classFiles) throws IOException {
             this.dir      = CacheDir.create("mount", id);
             this.refCount = 1;
+            this.classFiles = classFiles;
         }
 
         public synchronized String getMountPoint() {
@@ -202,7 +227,15 @@ public class MountManager {
             return refCount;
         }
 
+        public boolean classFiles() {
+            return classFiles;
+        }
+        public boolean setClassFiles() {
+            return classFiles == true;
+        }
+
         private File dir;
         private int  refCount;
+        private boolean classFiles;
     };
 }



More information about the libbluray-devel mailing list