]> Nishi Git Mirror - gwion.git/commitdiff
:art: Use globbing
authorfennecdjay <astor.jeremie@wanadoo.fr>
Thu, 14 Mar 2019 21:06:20 +0000 (22:06 +0100)
committerfennecdjay <astor.jeremie@wanadoo.fr>
Thu, 14 Mar 2019 21:06:20 +0000 (22:06 +0100)
.travis.yml
src/plug.c

index c91f6f856763d584cbaf8099496424b67d22141f..65bb496243be160fd3a48b04a104d7325e27a721 100644 (file)
@@ -3,7 +3,7 @@ language: c
 os:
   - linux
 #  - osx
-#  - windows
+  - windows
 
 addons:
 #  coverity_scan:
@@ -35,11 +35,11 @@ env:
   - USE_DOUBLE=1
   - USE_DOUBLE=0
 
-#matrix:
-#  allow_failures:
-#   - os:
+matrix:
+  allow_failures:
+   - os:
 #     - osx
-#     - windows
+     - windows
 
 compiler:
   - gcc
index 0df04f8ca79bfe7c2fcd8a039194f841d4b3b32a..0eb8beab6f2944f07941f63ba9019c4fe6bfee3a 100644 (file)
 #include "object.h"
 #include "import.h"
 #include "gwion.h"
-
-static inline int so_filter(const struct dirent* dir) {
-  return strstr(dir->d_name, ".so") ? 1 : 0;
-}
+#include "glob.h"
 
 typedef m_bool (*import)(Gwi);
 typedef m_str  (*modstr)(void);
@@ -69,17 +66,15 @@ ANN PlugInfo* new_plug(const Vector list) {
   map_init(&p->drv);
   for(m_uint i = 0; i < vector_size(list); i++) {
    const m_str dir = (m_str)vector_at(list, i);
-   struct dirent **file;
-   int n = scandir(dir, &file, so_filter, alphasort);
-   if(n > 0) {
-     while(n--) {
-       char c[strlen(dir) + strlen(file[n]->d_name) + 2];
-       sprintf(c, "%s/%s", dir, file[n]->d_name);
-       plug_get(p, c);
-       free(file[n]);
-      }
-     free(file);
-    }
+   char gname[strlen(dir) + 6];
+   strcpy(gname, dir);
+   strcpy(gname + strlen(dir), "/*.so");
+   glob_t results;
+   if(glob(gname, 0, NULL, &results))
+     continue;
+   for(int i = 0; i < results.gl_pathc; i++)
+       plug_get(p, results.gl_pathv[i]);
+    globfree(& results);
   }
   return p;
 }