+// 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, 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 (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()
+