[libbluray-devel] CacheDir: avoid double dir separators

hpi1 git at videolan.org
Tue Mar 3 13:05:11 CET 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Mar  3 13:34:00 2015 +0200| [cccfcadc849797ae0c05642f8051c3abafcc17e4] | committer: hpi1

CacheDir: avoid double dir separators

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

 src/libbluray/bdj/java/org/videolan/CacheDir.java |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/CacheDir.java b/src/libbluray/bdj/java/org/videolan/CacheDir.java
index 30b4cd2..22f5ea2 100644
--- a/src/libbluray/bdj/java/org/videolan/CacheDir.java
+++ b/src/libbluray/bdj/java/org/videolan/CacheDir.java
@@ -31,11 +31,10 @@ class CacheDir {
     }
 
     private static void cleanupCache() {
-        File baseDirFile = new File(baseDir);
-        String[] files = BDFileSystem.nativeList(baseDirFile);
+        String[] files = BDFileSystem.nativeList(baseDir);
         if (files != null) {
             for (int i = 0; i < files.length; i++) {
-                File dir = new File(baseDirFile, files[i]);
+                File dir = new File(baseDir, files[i]);
                 if (dir.isDirectory()) {
                     LockFile lock = lockCache(dir.getPath());
                     if (lock != null) {
@@ -56,14 +55,14 @@ class CacheDir {
         SecurityManager sm = System.getSecurityManager();
         if (sm != null && sm instanceof BDJSecurityManager) {
             ((BDJSecurityManager)sm).setCacheRoot(System.getProperty("java.io.tmpdir"));
-            new File(baseDir).mkdirs();
-            ((BDJSecurityManager)sm).setCacheRoot(baseDir);
+            baseDir.mkdirs();
+            ((BDJSecurityManager)sm).setCacheRoot(baseDir.getPath());
         }
 
         cleanupCache();
 
         for (int i = 0; i < 100; i++) {
-            File tmpDir = new File(baseDir + System.nanoTime());
+            File tmpDir = new File(baseDir, "" + System.nanoTime());
             tmpDir = new File(tmpDir.getCanonicalPath());
 
             if (tmpDir.mkdirs()) {
@@ -86,7 +85,7 @@ class CacheDir {
 
     public static synchronized File create(String domain) throws IOException {
 
-        File tmpDir = new File(getCacheRoot().getPath() + File.separator + domain);
+        File tmpDir = new File(getCacheRoot(), domain);
         if (!tmpDir.exists() && !tmpDir.mkdirs()) {
             logger.error("Error creating " + tmpDir.getPath());
             throw new IOException();
@@ -148,7 +147,6 @@ class CacheDir {
 
     private static File cacheRoot = null;
     private static LockFile lockFile = null;
-
-    private static final String baseDir = System.getProperty("java.io.tmpdir") + File.separator + "libbluray-bdj-cache" + File.separator;
+    private static final File baseDir = new File(System.getProperty("java.io.tmpdir"), "libbluray-bdj-cache");
     private static final Logger logger = Logger.getLogger(CacheDir.class.getName());
 }



More information about the libbluray-devel mailing list