JAL-4477 Using FileUtils.mkdirs(file) instead of file.mkdirs() in getdown and FileUtils
authorBen Soares <b.soares@dundee.ac.uk>
Tue, 29 Oct 2024 11:50:34 +0000 (11:50 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Tue, 29 Oct 2024 11:50:34 +0000 (11:50 +0000)
13 files changed:
getdown/lib/getdown-core.jar
getdown/lib/getdown-launcher-local.jar
getdown/lib/getdown-launcher.jar
getdown/src/getdown/core/src/main/java/com/threerings/getdown/cache/ResourceCache.java
getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java
getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java
getdown/src/getdown/core/src/main/java/com/threerings/getdown/net/Downloader.java
getdown/src/getdown/core/src/main/java/com/threerings/getdown/tools/Patcher.java
getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/FileUtil.java
getdown/src/getdown/core/src/main/java/jalview/util/FileUtils.java
j11lib/getdown-core.jar
j8lib/getdown-core.jar
src/jalview/util/FileUtils.java

index 9a9d765..c145270 100644 (file)
Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ
index a000f73..a2d604e 100644 (file)
Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ
index 6999be9..1676032 100644 (file)
Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ
index 0210e9a..c886efb 100644 (file)
@@ -8,6 +8,8 @@ package com.threerings.getdown.cache;
 import java.io.File;
 import java.io.IOException;
 
+import jalview.util.FileUtils;
+
 import com.threerings.getdown.util.FileUtil;
 
 /**
@@ -24,7 +26,7 @@ public class ResourceCache
 
     private void createDirectoryIfNecessary (File dir) throws IOException
     {
-        if (!dir.exists() && !dir.mkdirs()) {
+        if (!dir.exists() && !FileUtils.mkdirs(dir)) {
             throw new IOException("unable to create directory: " + dir.getAbsolutePath());
         }
     }
index fb510ef..047269d 100644 (file)
@@ -2085,7 +2085,7 @@ public class Application
       //  return false;
       //}
       if (!userAppDir.exists()) {
-        userAppDir.mkdirs();
+        FileUtils.mkdirs(userAppDir);
       }
       if (!(applicationAppDir.isDirectory() && userAppDir.isDirectory())) {
         log.warning("Parameter not a directory", "applicaitonAppDirName", applicationAppDirName, "userAppDirName", userAppDirName);
@@ -2186,7 +2186,7 @@ public class Application
           continue;
         }
         if (!to.getParentFile().exists()) {
-          to.getParentFile().mkdirs();
+          FileUtils.mkdirs(to.getParentFile());
         }
         try {
           Files.copy(from.toPath(), to.toPath(), StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.COPY_ATTRIBUTES);
index 44ad75d..bdaba7a 100644 (file)
@@ -277,7 +277,7 @@ public final class EnvConfig {
             // that runs getdown with an appdir and appbase specified, and have getdown create the
             // appdir and download the app into it
             if (!StringUtil.isBlank(appBase)) {
-                if (appDirFile.mkdirs()) {
+                if (FileUtils.mkdirs(appDirFile)) {
                     notes.add(Note.info("Auto-created app directory '" + appDir + "'"));
                 } else {
                     notes.add(Note.warn("Unable to auto-create app dir: '" + appDir + "'"));
index 6033e2f..5577fec 100644 (file)
@@ -15,6 +15,8 @@ import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.TimeUnit;
 
+import jalview.util.FileUtils;
+
 import com.threerings.getdown.data.Resource;
 
 import static com.threerings.getdown.Log.log;
@@ -58,7 +60,7 @@ public abstract class Downloader
         for (final Resource rsrc : resources) {
             // make sure the resource's target directory exists
             File parent = new File(rsrc.getLocal().getParent());
-            if (!parent.exists() && !parent.mkdirs()) {
+            if (!parent.exists() && !FileUtils.mkdirs(parent)) {
                 log.warning("Failed to create target directory for resource '" + rsrc + "'.");
             }
 
index c907e51..0a1c3b6 100644 (file)
@@ -19,6 +19,8 @@ import com.threerings.getdown.util.FileUtil;
 import com.threerings.getdown.util.ProgressObserver;
 import com.threerings.getdown.util.StreamUtil;
 
+import jalview.util.FileUtils;
+
 import static com.threerings.getdown.Log.log;
 
 /**
@@ -105,7 +107,7 @@ public class Patcher
 
         // make sure the file's parent directory exists
         File pdir = target.getParentFile();
-        if (!pdir.exists() && !pdir.mkdirs()) {
+        if (!pdir.exists() && !FileUtils.mkdirs(pdir)) {
             log.warning("Failed to create parent for '" + target + "'.");
         }
 
index e4a752b..249972a 100644 (file)
@@ -12,6 +12,8 @@ import java.util.*;
 import java.util.jar.*;
 import java.util.zip.GZIPInputStream;
 
+import jalview.util.FileUtils;
+
 import com.threerings.getdown.util.StreamUtil;
 import com.threerings.getdown.Log;
 import static com.threerings.getdown.Log.log;
@@ -155,7 +157,7 @@ public class FileUtil
             // but some do not, so we want to ensure that our directories exist
             // prior to getting down and funky
             File parent = new File(efile.getParent());
-            if (!parent.exists() && !parent.mkdirs()) {
+            if (!parent.exists() && !FileUtils.mkdirs(parent)) {
                 log.warning("Failed to create jar entry parent", "jar", jar, "parent", parent);
                 continue;
             }
index 3d95175..2681de6 100644 (file)
@@ -290,7 +290,7 @@ public class FileUtils
       }
     }
 
-    return parentDir.mkdirs();
+    return mkdirs(parentDir);
   }
 
   /**
@@ -391,7 +391,7 @@ public class FileUtils
     try
     {
       Files.createDirectory(getCanonicalPath(file));
-      return true;
+      return file.exists();
     } catch (IOException e)
     {
       LaunchUtils.syserr(true, false, "Failed to make directory " + file
index 9a9d765..c145270 100644 (file)
Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ
index 9a9d765..c145270 100644 (file)
Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ
index 3d95175..2681de6 100644 (file)
@@ -290,7 +290,7 @@ public class FileUtils
       }
     }
 
-    return parentDir.mkdirs();
+    return mkdirs(parentDir);
   }
 
   /**
@@ -391,7 +391,7 @@ public class FileUtils
     try
     {
       Files.createDirectory(getCanonicalPath(file));
-      return true;
+      return file.exists();
     } catch (IOException e)
     {
       LaunchUtils.syserr(true, false, "Failed to make directory " + file