[libbluray-devel] Check mkdirs() result

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


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sat Jun 10 22:39:33 2017 +0300| [7d8c5199160ef7c3cce0c3ad8b27d59b498acdd0] | committer: hpi1

Check mkdirs() result

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

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

diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index 60fb4aee..a8c8e6f1 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -93,8 +93,8 @@ public class Libbluray {
     private static String canonicalize(String path, boolean create) {
         try {
             File dir = new File(path);
-            if (create) {
-                dir.mkdirs();
+            if (create && !dir.isDirectory() && !dir.mkdirs()) {
+                System.err.println("error creating directory " + path);
             }
             return dir.getCanonicalPath();
         } catch (Exception ioe) {
diff --git a/src/libbluray/bdj/java/org/videolan/MountManager.java b/src/libbluray/bdj/java/org/videolan/MountManager.java
index 652a8403..a113c29a 100644
--- a/src/libbluray/bdj/java/org/videolan/MountManager.java
+++ b/src/libbluray/bdj/java/org/videolan/MountManager.java
@@ -102,7 +102,9 @@ public class MountManager {
                     File out = new File(mountPoint.getMountPoint() + File.separator + entry.getName());
 
                     if (entry.isDirectory()) {
-                        out.mkdirs();
+                        if (!out.isDirectory() && !out.mkdirs()) {
+                            logger.error("Error creating directory " + out.getPath());
+                        }
                     } else if (!classFiles && entry.getName().endsWith(".class")) {
                         // logger.info("skip " + entry.getName());
                     } else {
@@ -112,7 +114,9 @@ public class MountManager {
                         /* make sure path exists */
                         File dir = out.getParentFile();
                         if (dir != null) {
-                            dir.mkdirs();
+                            if (!dir.isDirectory() && !dir.mkdirs()) {
+                                logger.error("Error creating directory " + dir.getPath());
+                            }
                         }
 
                         try {



More information about the libbluray-devel mailing list