[libbluray-devel] Change baseDir in CacheDir class to handle 8.3 file name convention in Windows

tourettes git at videolan.org
Fri Mar 6 09:06:51 CET 2015


libbluray | branch: master | tourettes <tourettes at team-mediaportal.com> | Thu Mar  5 22:13:08 2015 +0200| [78c374250c87d0681e72695b37208cb6e870b27f] | committer: hpi1

Change baseDir in CacheDir class to handle 8.3 file name convention in Windows

Java can use 8.3 file name convention when asked for the OS temporary folder.

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

 src/libbluray/bdj/java/org/videolan/CacheDir.java |   24 +++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/CacheDir.java b/src/libbluray/bdj/java/org/videolan/CacheDir.java
index 8118bb4..817928e 100644
--- a/src/libbluray/bdj/java/org/videolan/CacheDir.java
+++ b/src/libbluray/bdj/java/org/videolan/CacheDir.java
@@ -30,7 +30,21 @@ class CacheDir {
         return LockFile.create(path + File.separator + "lock");
     }
 
-    private static void cleanupCache() {
+    private static void InitializeBaseDir() throws IOException {
+        if (baseDir == null) {
+            try {
+                File tmpDir = new File(System.getProperty("java.io.tmpdir"), "libbluray-bdj-cache");
+                baseDir = new File(tmpDir.getCanonicalPath());
+            }
+            catch (IOException e) {
+                logger.error("Error in initializing baseDir " + e);
+                throw e;
+            }
+        }
+    }
+
+    private static void cleanupCache() throws IOException {
+        InitializeBaseDir();
         String[] files = BDFileSystem.nativeList(baseDir);
         if (files != null) {
             for (int i = 0; i < files.length; i++) {
@@ -54,9 +68,11 @@ class CacheDir {
 
         BDJSecurityManager sm = (BDJSecurityManager)System.getSecurityManager();
         if (sm != null) {
-            sm.setCacheRoot(System.getProperty("java.io.tmpdir"));
+            InitializeBaseDir();
+            File tmpDir = new File(System.getProperty("java.io.tmpdir"));
+            sm.setCacheRoot(tmpDir.getCanonicalPath());
             baseDir.mkdirs();
-            sm.setCacheRoot(baseDir.getPath());
+            sm.setCacheRoot(baseDir.getCanonicalPath());
         }
 
         cleanupCache();
@@ -147,6 +163,6 @@ class CacheDir {
 
     private static File cacheRoot = null;
     private static LockFile lockFile = null;
-    private static final File baseDir = new File(System.getProperty("java.io.tmpdir"), "libbluray-bdj-cache");
+    private static File baseDir = null;
     private static final Logger logger = Logger.getLogger(CacheDir.class.getName());
 }



More information about the libbluray-devel mailing list