]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
More changes for httpfs: if a .packs-only file exists, do not try to
authorRudolf Polzer <divVerent@xonotic.org>
Thu, 24 Sep 2015 18:28:52 +0000 (14:28 -0400)
committerRudolf Polzer <divVerent@xonotic.org>
Thu, 24 Sep 2015 18:28:52 +0000 (14:28 -0400)
look inside a directory; add a flag -http_cache_content.

filematch.c
fs.c
sys_sdl.c

index ae51599bf8969a4220a6279081c69e8cd92ab26d..573b8447fae8126f88d99139e7d064451828724a 100644 (file)
@@ -219,7 +219,6 @@ void listdirectory(stringlist_t *list, const char *basepath, const char *path)
                        if (q == NULL)
                                break;
                        *q = 0;
-                        Con_Printf("Got file: %s\n", p);
                        adddirentry(list, path, p);
                        p = q + 1;
                }
diff --git a/fs.c b/fs.c
index 550503cbf769060897fadcb53aab93a44e77238a..2a471a2d05889e7ac369785d61ce780ffacf2a6a 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1240,11 +1240,6 @@ static void FS_AddGameDirectory (const char *dir, qboolean iscache)
        stringlist_t list;
        searchpath_t *search;
 
-       if (iscache)
-               strlcpy (fs_gamedir, dir, sizeof (fs_gamedir));
-       else
-               strlcpy (fs_gamecachedir, dir, sizeof (fs_gamedir));
-
        stringlistinit(&list);
        listdirectory(&list, "", dir);
        stringlistsort(&list, false);
@@ -1267,14 +1262,34 @@ static void FS_AddGameDirectory (const char *dir, qboolean iscache)
                }
        }
 
+       // test if we want to add the dir itself too
+       qboolean add_unpacked = true;
+       for (i = 0;i < list.numstrings;i++)
+       {
+               if (!strcasecmp(list.strings[i] + strlen(dir), ".packs-only"))
+               {
+                       Con_Printf("Found %s/.packs-only file - not loading other files from there.", dir);
+                       add_unpacked = false;
+               }
+       }
+
        stringlistfreecontents(&list);
 
-       // Add the directory to the search path
-       // (unpacked files have the priority over packed files)
-       search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t));
-       strlcpy (search->filename, dir, sizeof (search->filename));
-       search->next = fs_searchpaths;
-       fs_searchpaths = search;
+       if (add_unpacked)
+       {
+               // Add the directory to the search path
+               // (unpacked files have the priority over packed files)
+               search = (searchpath_t *)Mem_Alloc(fs_mempool, sizeof(searchpath_t));
+               strlcpy (search->filename, dir, sizeof (search->filename));
+               search->next = fs_searchpaths;
+               fs_searchpaths = search;
+
+               // Register the directory as a writable path.
+               if (iscache)
+                       strlcpy (fs_gamedir, dir, sizeof (fs_gamedir));
+               else
+                       strlcpy (fs_gamecachedir, dir, sizeof (fs_gamedir));
+       }
 }
 
 
index 2ba791b671ec3ccff9c5796e7eb4111fd797f977..34ceb2469c458b33d9bf8dc0d417764a69e6a52b 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -205,12 +205,21 @@ void Sys_InitConsole (void)
 #include <sys/mount.h>
 static void NaCl_Init(void)
 {
+       char vabuf[1024];
+
        mount("", "/dev", "dev", 0, "");
        mount("", "/.config", "html5fs", 0, "type=PERSISTENT,expected_size=8388608");
        mount("", "/.cache", "html5fs", 0, "type=TEMPORARY,expected_size=1073741824");
-       mount("", "/http", "httpfs", 0, "cache_stat=true,cache_content=false");
-       int fd = open("/dev/console0", O_WRONLY, 0644);
-       outfd = fd;
+
+       const char *http_root = "";
+       int i = COM_CheckParm("-http_root");
+       if (i && i < com_argc - 1)
+               http_root = com_argv[i + 1];
+       int cache_content = COM_CheckParm("-http_cache_content");
+
+       mount(http_root, "/http", "httpfs", 0, va(vabuf, sizeof(vabuf),
+               "cache_stat=true,cache_content=%s,allow_cross_origin_requests=true",
+               cache_content ? "true" : "false"));
 }
 #endif