]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - filematch.c
Fix bugs in ModList_RebuildList such that it no longer lists files in the quake direc...
[xonotic/darkplaces.git] / filematch.c
index 42f9f9dbcbeb8f3d0e31d64d6138a51112ddae9e..59e626d2a9ee9d77c522aae2744382441ce44d25 100644 (file)
@@ -125,6 +125,8 @@ static int stringlistsort_cmp(const void *a, const void *b)
 void stringlistsort(stringlist_t *list, qboolean uniq)
 {
        int i, j;
+       if(list->numstrings < 1)
+               return;
        qsort(&list->strings[0], list->numstrings, sizeof(list->strings[0]), stringlistsort_cmp);
        if(uniq)
        {
@@ -190,10 +192,36 @@ void listdirectory(stringlist_t *list, const char *basepath, const char *path)
        char fullpath[MAX_OSPATH];
        DIR *dir;
        struct dirent *ent;
-       dpsnprintf(fullpath, sizeof(fullpath), "%s%s", basepath, *path ? path : "./");
+       dpsnprintf(fullpath, sizeof(fullpath), "%s%s", basepath, path);
+#ifdef __ANDROID__
+       // SDL currently does not support listing assets, so we have to emulate
+       // it. We're using relative paths for assets, so that will do.
+       if (basepath[0] != '/')
+       {
+               char listpath[MAX_OSPATH];
+               qfile_t *listfile;
+               dpsnprintf(listpath, sizeof(listpath), "%sls.txt", fullpath);
+               char *buf = (char *) FS_SysLoadFile(listpath, tempmempool, true, NULL);
+               if (!buf)
+                       return;
+               char *p = buf;
+               for (;;)
+               {
+                       char *q = strchr(p, '\n');
+                       if (q == NULL)
+                               break;
+                       *q = 0;
+                       adddirentry(list, path, p);
+                       p = q + 1;
+               }
+               Mem_Free(buf);
+               return;
+       }
+#endif
        dir = opendir(fullpath);
        if (!dir)
                return;
+
        while ((ent = readdir(dir)))
                adddirentry(list, path, ent->d_name);
        closedir(dir);