]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
On NaCl, opendir() is prone to fail (e.g. on httpfs). Emulate it via .ls.txt files...
authorRudolf Polzer <divVerent@xonotic.org>
Wed, 23 Sep 2015 00:07:24 +0000 (02:07 +0200)
committerRudolf Polzer <divVerent@xonotic.org>
Wed, 23 Sep 2015 00:07:24 +0000 (02:07 +0200)
filematch.c

index 997116766de56c1bf599543a16cb69dc0d9dfa21..754d362c23e2c4d423ed4ff6712fe8e1233553cb 100644 (file)
@@ -195,7 +195,28 @@ void listdirectory(stringlist_t *list, const char *basepath, const char *path)
        dpsnprintf(fullpath, sizeof(fullpath), "%s%s", basepath, *path ? path : "./");
        dir = opendir(fullpath);
        if (!dir)
+#ifdef __native_client__
+       {
+               char listpath[MAX_OSPATH];
+               dpsnprintf(listpath, sizeof(listpath), "%s.ls.txt", fullpath);
+               char *buf = (char *) FS_LoadFile(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);
+       }
+#else
                return;
+#endif
        while ((ent = readdir(dir)))
                adddirentry(list, path, ent->d_name);
        closedir(dir);