]> code.delx.au - refind/blobdiff - refind/config.c
New config file option: "also_scan_dirs".
[refind] / refind / config.c
index 8f955e142cebad0b3f192f6f075cdaca6b49c233..7ad8f91b423e8642e7c3611378ff9034c6ae5fbb 100644 (file)
@@ -357,7 +357,16 @@ VOID ReadConfig(VOID)
               else
                  GlobalConfig.ScanFor[i] = ' ';
            }
-        } else if (StriCmp(TokenList[0], L"showtools") == 0) {
+
+        } else if (StriCmp(TokenList[0], L"also_scan_dirs") == 0) {
+           if (GlobalConfig.AlsoScan != NULL) {
+              FreePool(GlobalConfig.AlsoScan);
+              GlobalConfig.AlsoScan = NULL;
+           } // if
+           for (i = 1; i < TokenCount; i++)
+              MergeStrings(&GlobalConfig.AlsoScan, TokenList[i], L',');
+
+      } else if (StriCmp(TokenList[0], L"showtools") == 0) {
             SetMem(GlobalConfig.ShowTools, NUM_TOOLS * sizeof(UINTN), 0);
             for (i = 1; (i < TokenCount) && (i < NUM_TOOLS); i++) {
                 FlagName = TokenList[i];
@@ -389,7 +398,7 @@ VOID ReadConfig(VOID)
 
         } else if (StriCmp(TokenList[0], L"default_selection") == 0) {
             HandleString(TokenList, TokenCount, &(GlobalConfig.DefaultSelection));
-            
+
         } else if (StriCmp(TokenList[0], L"textonly") == 0) {
             GlobalConfig.TextOnly = TRUE;
 
@@ -461,24 +470,40 @@ static VOID AddSubmenu(LOADER_ENTRY *Entry, REFIT_FILE *File, REFIT_VOLUME *Volu
    Entry->me.SubScreen = SubScreen;
 } // VOID AddSubmenu()
 
-// Finds a volume with the specified Identifier (a volume label, for the moment).
-// If found, sets *Volume to point to that volume. If not, leaves it unchanged.
+// Finds a volume with the specified Identifier (a volume label or a number
+// followed by a colon, for the moment). If found, sets *Volume to point to
+// that volume. If not, leaves it unchanged.
 // Returns TRUE if a match was found, FALSE if not.
 static BOOLEAN FindVolume(REFIT_VOLUME **Volume, CHAR16 *Identifier) {
-   UINTN     i = 0;
+   UINTN     i = 0, CountedVolumes = 0;
+   INTN      Number = -1;
    BOOLEAN   Found = FALSE;
 
+   if ((StrLen(Identifier) >= 2) && (Identifier[StrLen(Identifier) - 1] == L':') &&
+       (Identifier[0] >= L'0') && (Identifier[0] <= L'9')) {
+      Number = (INTN) Atoi(Identifier);
+   }
    while ((i < VolumesCount) && (!Found)) {
-      if (StriCmp(Identifier, Volumes[i]->VolName) == 0) {
-         *Volume = Volumes[i];
-         Found = TRUE;
-      } // if
+      if (Number >= 0) { // User specified a volume by number
+         if (Volumes[i]->IsReadable) {
+            if (CountedVolumes == Number) {
+               *Volume = Volumes[i];
+               Found = TRUE;
+            }
+            CountedVolumes++;
+         } // if
+      } else { // User specified a volume by label
+         if (StriCmp(Identifier, Volumes[i]->VolName) == 0) {
+            *Volume = Volumes[i];
+            Found = TRUE;
+         } // if
+      } // if/else
       i++;
    } // while()
    return (Found);
 } // static VOID FindVolume()
 
-// Adds the options from a SINGLE loaders.conf stanza to a new loader entry and returns
+// Adds the options from a SINGLE refind.conf stanza to a new loader entry and returns
 // that entry. The calling function is then responsible for adding the entry to the
 // list of entries.
 static LOADER_ENTRY * AddStanzaEntries(REFIT_FILE *File, REFIT_VOLUME *Volume, CHAR16 *Title) {