JAL-4487 Escape backslash file separators when looking for file globs. Fixed a CLI...
authorBen Soares <b.soares@dundee.ac.uk>
Wed, 6 Nov 2024 00:51:45 +0000 (00:51 +0000)
committerBen Soares <b.soares@dundee.ac.uk>
Wed, 6 Nov 2024 00:51:45 +0000 (00:51 +0000)
src/jalview/bin/Commands.java
src/jalview/gui/Preferences.java
src/jalview/util/FileUtils.java

index c4b532b..31a2909 100644 (file)
@@ -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);
 
index 84dff9c..04fd9ed 100755 (executable)
@@ -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)
     {
index f2883a7..7950de4 100644 (file)
@@ -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()