From f7fd0e8b5d87cf937b2f6afdc0e564891691feba Mon Sep 17 00:00:00 2001
From: Francesco Andreuzzi <andreuzzi.francesco@gmail.com>
Date: Mon, 6 Jun 2016 20:40:57 +0200
Subject: [PATCH] fixed aaa.* bug

---
 .../consolelauncher/managers/FileManager.java | 32 ++++++++++++++-----
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java b/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java
index 09c6614..ff27caa 100755
--- a/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java
+++ b/app/src/main/java/ohi/andre/consolelauncher/managers/FileManager.java
@@ -23,7 +23,9 @@ public class FileManager {
     public static final int ISFILE = 13;
 
     public static final boolean USE_SCROLL_COMPARE = true;
-    public static final String ALL = "allFiles";
+
+    private static final String ASTERISK = "*";
+    private static final String DOT = Tuils.DOT;
 
     public static int mv(File[] files, File where, boolean su) throws IOException {
         if (files == null || files.length == 0 || where == null)
@@ -274,16 +276,14 @@ public class FileManager {
         return new DirInfo(file, notFound);
     }
 
-    public static String wildcard(String path) {
-        if (path == null || !path.contains("*") || path.contains("/"))
+    public static WildcardInfo wildcard(String path) {
+        if (path == null || !path.contains(ASTERISK) || path.contains("/"))
             return null;
 
-//        if there is only "*", means that you have to select all files in folder
-        String after = path.substring(path.indexOf("*") + 1);
-        if (after.length() == 0)
-            return ALL;
+        String beforeDot = path.substring(0, path.lastIndexOf(DOT));
+        String afterDot = path.substring(path.lastIndexOf(DOT) + 1);
 
-        return after;
+        return new WildcardInfo(beforeDot, afterDot);
     }
 
     public static class DirInfo {
@@ -295,4 +295,20 @@ public class FileManager {
             this.notFound = nF;
         }
     }
+
+    public static class WildcardInfo {
+
+        public boolean allNames;
+        public boolean allExtensions;
+        public String name;
+        public String extension;
+
+        public WildcardInfo(String name, String extension) {
+            this.name = name;
+            this.extension = extension;
+
+            allNames = name.length() == 0 || name.equals(ASTERISK);
+            allExtensions = extension.length() == 0 || extension.equals(ASTERISK);
+        }
+    }
 }
-- 
GitLab