force filenames to lowercase in listdirectory code on windows
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 30 Mar 2002 03:04:49 +0000 (03:04 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 30 Mar 2002 03:04:49 +0000 (03:04 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@1691 d7cf8633-e32d-0410-b094-e92efae38249

filematch.c

index 9ac6491..9e0ecea 100644 (file)
@@ -113,7 +113,7 @@ stringlist_t *stringlistsort(stringlist_t *start)
 #include <io.h>
 stringlist_t *listdirectory(char *path)
 {
-       char pattern[4096];
+       char pattern[4096], *c;
        struct _finddata_t n_file;
     long hFile;
        stringlist_t *start, *current;
@@ -129,8 +129,16 @@ stringlist_t *listdirectory(char *path)
                while (_findnext(hFile, &n_file) == 0)
                        current = stringlistappend(current, n_file.name);
                _findclose(hFile);
+
+               // convert names to lowercase because windows does not care, but pattern matching code often does
+               for (current = start;current;current = current->next)
+                       for (c = current->text;*c;c++)
+                               if (*c >= 'A' && *c <= 'Z')
+                                       *c += 'a' - 'A';
+
                // sort the list alphanumerically
-               return stringlistsort(start);
+               start = stringlistsort(start);
+               return start;
        }
        else
                return NULL;