]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - plugins/vfspk3/vfs.cpp
handle forbidden dir exclusions properly now
[xonotic/netradiant.git] / plugins / vfspk3 / vfs.cpp
index e10c1ce636c1a5f9417883267833dee3dd7e684c..86a2ac85f4cead9909bd9a033ac73e255fb1f4ed 100644 (file)
@@ -60,6 +60,7 @@ ArchiveModules& FileSystemQ3API_getArchiveModules();
 #include "stream/stringstream.h"
 #include "os/path.h"
 #include "moduleobservers.h"
+#include "filematch.h"
 
 
 #define VFS_MAXDIRS 64
@@ -315,11 +316,17 @@ void InitDirectory(const char* directory, ArchiveModules& archiveModules)
 
   for(j = 0; j < g_numForbiddenDirs; ++j)
   {
-    printf("match against %s?\n", g_strForbiddenDirs[j]);
-    if(!string_compare_nocase_upper(directory, g_strForbiddenDirs[j])
-    || (string_length(directory) > string_length(g_strForbiddenDirs[j]) && directory[string_length(directory) - string_length(g_strForbiddenDirs[j]) - 1] == '/' && !string_compare_nocase_upper(directory + string_length(directory) - string_length(g_strForbiddenDirs[j]), g_strForbiddenDirs[j])))
+    char* dbuf = g_strdup(directory);
+    if(*dbuf && dbuf[strlen(dbuf)-1] == '/')
+      dbuf[strlen(dbuf)-1] = 0;
+    const char *p = strrchr(dbuf, '/');
+    p = (p ? (p+1) : dbuf);
+    if(matchpattern(p, g_strForbiddenDirs[j], TRUE))
+    {
+      g_free(dbuf);
       break;
-    printf("not matched\n");
+    }
+    g_free(dbuf);
   }
   if(j < g_numForbiddenDirs)
   {
@@ -382,9 +389,13 @@ void InitDirectory(const char* directory, ArchiveModules& archiveModules)
         if(name == 0)
           break;
 
-       for(j = 0; j < g_numForbiddenDirs; ++j)
-         if(!string_compare_nocase_upper(name, g_strForbiddenDirs[j]))
-           break;
+        for(j = 0; j < g_numForbiddenDirs; ++j)
+        {
+          const char *p = strrchr(name, '/');
+          p = (p ? (p+1) : name);
+          if(matchpattern(p, g_strForbiddenDirs[j], TRUE))
+            break;
+        }
        if(j < g_numForbiddenDirs)
          continue;