Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 58ed6038 authored by jaffersulaiman's avatar jaffersulaiman Committed by Ed Carrigan
Browse files

Default file manager fails to search files with Russian file name

Changed Find command argument name to iname in command_list xml.
square brackets and upper case format removed from searchHelper class

Bug: CYNGNOS-2273
Change-Id: I40fe203929656055e209f10f6284c0b39634a6fb
(cherry picked from commit de3fb3d0)
parent 162328a1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@
  <!-- List/Find/Info -->
  <command commandId="ls" commandPath="/system/bin/ls" commandArgs="%1$s 1&gt; /dev/null &amp;&amp; /system/bin/stat -t %1$s.* %1$s* 2&gt; /dev/null" />
  <command commandId="fileinfo" commandPath="/system/bin/stat" commandArgs="-t %1$s" />
  <command commandId="find" commandPath="/system/bin/find" commandArgs="%1$s \\( -name %2$s -o -name %3$s -o -name %4$s -o -name %5$s -o -name %6$s \\) -exec /system/bin/stat -t {} 2&gt;&amp;1 \\;" />
  <command commandId="find" commandPath="/system/bin/find" commandArgs="%1$s \\( -iname %2$s -o -name %3$s -o -name %4$s -o -name %5$s -o -name %6$s \\) -exec /system/bin/stat -t {} 2&gt;&amp;1 \\;" />
  <command commandId="quickfoldersearch" commandPath="/system/bin/ls" commandArgs="-aFd %1$s.* %1$s* 2&gt; /dev/null | /system/bin/grep -e '^d' -e '^ld' | /system/bin/cut -d&quot; &quot; -f2-" />
  <command commandId="readlink" commandPath="/system/bin/ls" commandArgs="%1$s 1&gt; /dev/null &amp;&amp; /system/bin/stat -t -L %1$s 2&gt;&amp;1" />

+1 −1
Original line number Diff line number Diff line
@@ -268,7 +268,7 @@ public class FindCommand extends Program implements FindExecutable {
        String[] args = new String[query.getSlotsCount()];
        int cc = query.getSlotsCount();
        for (int i = 0; i < cc; i++) {
            args[i] = SearchHelper.toIgnoreCaseRegExp(query.getSlot(i), true);
            args[i] = SearchHelper.toRegExp(query.getSlot(i), true);
        }
        return args;
    }
+1 −1
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ public class FindCommand extends Program implements FindExecutable {
        String[] args = new String[query.getSlotsCount()];
        int cc = query.getSlotsCount();
        for (int i = 0; i < cc; i++) {
            args[i] = SearchHelper.toIgnoreCaseRegExp(query.getSlot(i), true);
            args[i] = SearchHelper.toRegExp(query.getSlot(i), true);
        }
        return args;
    }
+1 −1
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ public class FindCommand extends AsyncResultProgram implements FindExecutable {
        args[0] = directory;
        int cc = query.getSlotsCount();
        for (int i = 0; i < cc; i++) {
            args[i + 1] = SearchHelper.toIgnoreCaseRegExp(query.getSlot(i), false);
            args[i + 1] = SearchHelper.toRegExp(query.getSlot(i), false);
        }
        return args;
    }
+2 −20
Original line number Diff line number Diff line
@@ -58,7 +58,7 @@ public final class SearchHelper {
     * @return String The regular expressions of the query to match an ignore case search
     */
    @SuppressWarnings("boxing")
    public static String toIgnoreCaseRegExp(final String query, boolean javaRegExp) {
    public static String toRegExp(final String query, boolean javaRegExp) {
        //Check that all is correct
        if (query == null || query.trim().length() == 0) {
            return "";  //$NON-NLS-1$
@@ -70,28 +70,10 @@ public final class SearchHelper {
            q = prepareQuery(q);
        }

        //Convert the string to lower and upper
        final String lowerCase = q.toLowerCase(Locale.ROOT);
        final String upperCase = q.toUpperCase(Locale.ROOT);

        //Create the regular expression filter
        StringBuffer sb = new StringBuffer();
        int cc = lowerCase.length();
        for (int i = 0; i < cc; i++) {
            char lower = lowerCase.charAt(i);
            char upper = upperCase.charAt(i);
            if (lower != upper) {
                //Convert to expression
                sb.append(String.format("[%s%s]", lower, upper)); //$NON-NLS-1$
            } else {
                //Not need to convert
                sb.append(lower);
            }
        }
        return String.format(
                    "%s%s%s",  //$NON-NLS-1$;
                    javaRegExp ? REGEXP_WILCARD_JAVA : REGEXP_WILCARD,
                    sb.toString(), javaRegExp ? REGEXP_WILCARD_JAVA : REGEXP_WILCARD);
                    q, javaRegExp ? REGEXP_WILCARD_JAVA : REGEXP_WILCARD);
    }

    /**