From: Ben Soares Date: Tue, 29 Oct 2024 11:50:34 +0000 (+0000) Subject: JAL-4477 Using FileUtils.mkdirs(file) instead of file.mkdirs() in getdown and FileUtils X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=72e4e0a59415bfbfc3894b3c2ed8a0a881b1b7f8;p=jalview.git JAL-4477 Using FileUtils.mkdirs(file) instead of file.mkdirs() in getdown and FileUtils --- diff --git a/getdown/lib/getdown-core.jar b/getdown/lib/getdown-core.jar index 9a9d765..c145270 100644 Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ diff --git a/getdown/lib/getdown-launcher-local.jar b/getdown/lib/getdown-launcher-local.jar index a000f73..a2d604e 100644 Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ diff --git a/getdown/lib/getdown-launcher.jar b/getdown/lib/getdown-launcher.jar index 6999be9..1676032 100644 Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/cache/ResourceCache.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/cache/ResourceCache.java index 0210e9a..c886efb 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/cache/ResourceCache.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/cache/ResourceCache.java @@ -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()); } } diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java index fb510ef..047269d 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java @@ -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); diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java index 44ad75d..bdaba7a 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/EnvConfig.java @@ -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 + "'")); diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/net/Downloader.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/net/Downloader.java index 6033e2f..5577fec 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/net/Downloader.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/net/Downloader.java @@ -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 + "'."); } diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/tools/Patcher.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/tools/Patcher.java index c907e51..0a1c3b6 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/tools/Patcher.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/tools/Patcher.java @@ -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 + "'."); } diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/FileUtil.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/FileUtil.java index e4a752b..249972a 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/FileUtil.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/util/FileUtil.java @@ -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; } diff --git a/getdown/src/getdown/core/src/main/java/jalview/util/FileUtils.java b/getdown/src/getdown/core/src/main/java/jalview/util/FileUtils.java index 3d95175..2681de6 100644 --- a/getdown/src/getdown/core/src/main/java/jalview/util/FileUtils.java +++ b/getdown/src/getdown/core/src/main/java/jalview/util/FileUtils.java @@ -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 diff --git a/j11lib/getdown-core.jar b/j11lib/getdown-core.jar index 9a9d765..c145270 100644 Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ diff --git a/j8lib/getdown-core.jar b/j8lib/getdown-core.jar index 9a9d765..c145270 100644 Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ diff --git a/src/jalview/util/FileUtils.java b/src/jalview/util/FileUtils.java index 3d95175..2681de6 100644 --- a/src/jalview/util/FileUtils.java +++ b/src/jalview/util/FileUtils.java @@ -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