[libbluray-devel] Fix checking if directory exists

hpi1 git at videolan.org
Thu Jun 15 00:09:33 CEST 2017


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sat Jun 10 22:40:29 2017 +0300| [9aa454ba773e29d63fcd32c25c301784a24cb5d3] | committer: hpi1

Fix checking if directory exists

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

 src/libbluray/bdj/java/org/videolan/BDJAppProxy.java | 2 +-
 src/libbluray/bdj/java/org/videolan/CacheDir.java    | 8 +++++---
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/BDJAppProxy.java b/src/libbluray/bdj/java/org/videolan/BDJAppProxy.java
index e0e2b75d..24125bff 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJAppProxy.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJAppProxy.java
@@ -213,7 +213,7 @@ class BDJAppProxy implements DVBJProxy, Runnable {
                     (String)context.getXletProperty("dvb.org.id") + File.separator +
                     (String)context.getXletProperty("dvb.app.id");
                 File f = new File(persistent);
-                if (!f.exists() && !f.mkdirs()) {
+                if (!f.isDirectory() && !f.mkdirs()) {
                     logger.error("Error creating persistent storage " + persistent);
                 }
                 xlet.initXlet(context);
diff --git a/src/libbluray/bdj/java/org/videolan/CacheDir.java b/src/libbluray/bdj/java/org/videolan/CacheDir.java
index 2406b664..bb7ff3b4 100644
--- a/src/libbluray/bdj/java/org/videolan/CacheDir.java
+++ b/src/libbluray/bdj/java/org/videolan/CacheDir.java
@@ -75,7 +75,9 @@ class CacheDir {
             InitializeBaseDir();
             File tmpDir = new File(System.getProperty("java.io.tmpdir"));
             sm.setCacheRoot(tmpDir.getCanonicalPath());
-            baseDir.mkdirs();
+            if (!baseDir.isDirectory() && !baseDir.mkdirs()) {
+                logger.error("Error creating directory " + baseDir.getPath());
+            }
             sm.setCacheRoot(baseDir.getCanonicalPath());
         }
 
@@ -106,8 +108,8 @@ class CacheDir {
     public static synchronized File create(String domain) throws IOException {
 
         File tmpDir = new File(getCacheRoot(), domain);
-        if (!tmpDir.exists() && !tmpDir.mkdirs()) {
-            logger.error("Error creating " + tmpDir.getPath());
+        if (!tmpDir.isDirectory() && !tmpDir.mkdirs()) {
+            logger.error("Error creating directory " + tmpDir.getPath());
             throw new IOException();
         }
 



More information about the libbluray-devel mailing list