From ba83c168c9af031ceae5db2b65e9eaf33434564d Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Wed, 23 Sep 2015 02:07:24 +0200 Subject: [PATCH] On NaCl, opendir() is prone to fail (e.g. on httpfs). Emulate it via .ls.txt files then. --- filematch.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/filematch.c b/filematch.c index 99711676..754d362c 100644 --- a/filematch.c +++ b/filematch.c @@ -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); -- 2.39.2