From: Ben Soares Date: Wed, 6 Nov 2024 00:51:45 +0000 (+0000) Subject: JAL-4487 Escape backslash file separators when looking for file globs. Fixed a CLI... X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7dd2e65dd82f622ef447070256e4c3659fe636ca;p=jalview.git JAL-4487 Escape backslash file separators when looking for file globs. Fixed a CLI and a debugging NPE. --- diff --git a/src/jalview/bin/Commands.java b/src/jalview/bin/Commands.java index c4b532b..31a2909 100644 --- a/src/jalview/bin/Commands.java +++ b/src/jalview/bin/Commands.java @@ -927,6 +927,11 @@ public class Commands boolean showSSAnnotations, boolean showAnnotations, boolean hideTFrows) { + if (af == null) + { + Console.warn("Expected Alignment Window not opened"); + return; + } af.setAnnotationsVisibility(showSSAnnotations, true, false); af.setAnnotationsVisibility(showAnnotations, false, true); diff --git a/src/jalview/gui/Preferences.java b/src/jalview/gui/Preferences.java index 84dff9c..04fd9ed 100755 --- a/src/jalview/gui/Preferences.java +++ b/src/jalview/gui/Preferences.java @@ -1468,8 +1468,13 @@ public class Preferences extends GPreferences Cache.enableSessionProperties(); structureViewerPath.setText(viewerPath); - jalview.bin.Console.debug("Found " + paths.size() - + " paths to look for " + selectedItem.toString()); + jalview.bin.Console + .debug("Found " + (paths == null ? null : paths.size()) + + " paths to look for " + selectedItem.toString()); + if (paths == null) + { + paths = new ArrayList<>(); + } paths.add(0, structureViewerPath.getText()); for (String path : paths) { diff --git a/src/jalview/util/FileUtils.java b/src/jalview/util/FileUtils.java index f2883a7..7950de4 100644 --- a/src/jalview/util/FileUtils.java +++ b/src/jalview/util/FileUtils.java @@ -95,6 +95,13 @@ public class FileUtils { String glob = "glob:" + parentDir.toString() + File.separator + rest; + if (Platform.isWin()) + { + // escape "\\" on Windows + // This ultimately replaces "\\" == '\' with "\\\\" = '\\' to escape + // backslashes + glob = glob.replaceAll("\\\\", "\\\\\\\\"); + } PathMatcher pm = FileSystems.getDefault().getPathMatcher(glob); int maxDepth = rest.contains("**") ? 1028 : (int) (rest.chars()