[libbluray-devel] Improve mounting .jar files.
hpi1
git at videolan.org
Fri Dec 13 10:45:51 CET 2013
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri Dec 13 11:34:24 2013 +0200| [fde1f886a24abfc10d58a93f8d49f0ea7b5c00c4] | committer: hpi1
Improve mounting .jar files.
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=fde1f886a24abfc10d58a93f8d49f0ea7b5c00c4
---
src/libbluray/bdj/java/org/videolan/MountManager.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/libbluray/bdj/java/org/videolan/MountManager.java b/src/libbluray/bdj/java/org/videolan/MountManager.java
index b80b9f7..e88a263 100644
--- a/src/libbluray/bdj/java/org/videolan/MountManager.java
+++ b/src/libbluray/bdj/java/org/videolan/MountManager.java
@@ -48,6 +48,12 @@ public class MountManager {
if (jarStr == null)
throw new IllegalArgumentException();
+ String oldPath = getMount(jarId);
+ if (oldPath != null) {
+ logger.error("JAR " + jarId + " already mounted");
+ return oldPath;
+ }
+
String path = System.getProperty("bluray.vfs.root") + "/BDMV/JAR/" + jarStr + ".jar";
JarFile jar = null;
@@ -65,11 +71,14 @@ public class MountManager {
tmpDir.mkdir();
try {
+ byte[] buffer = new byte[32*1024];
Enumeration entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = (JarEntry)entries.nextElement();
File out = new File(tmpDir + File.separator + entry.getName());
+ logger.info(" mount: " + entry.getName());
+
if (entry.isDirectory()) {
out.mkdirs();
} else {
@@ -79,8 +88,9 @@ public class MountManager {
InputStream inStream = jar.getInputStream(entry);
OutputStream outStream = new FileOutputStream(out);
- while (inStream.available() > 0) {
- outStream.write(inStream.read());
+ int length;
+ while ((length = inStream.read(buffer)) > 0) {
+ outStream.write(buffer, 0, length);
}
inStream.close();
@@ -93,6 +103,8 @@ public class MountManager {
throw new MountException();
}
+ logger.info("Mounting JAR " + jarId + " complete.");
+
mountPoints.put(new Integer(jarId), tmpDir);
return tmpDir.getAbsolutePath();
}
More information about the libbluray-devel
mailing list