summaryrefslogtreecommitdiff
path: root/plugins/pychrysa
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa')
-rw-r--r--plugins/pychrysa/pychrysa.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/plugins/pychrysa/pychrysa.c b/plugins/pychrysa/pychrysa.c
index f09c234..f959671 100644
--- a/plugins/pychrysa/pychrysa.c
+++ b/plugins/pychrysa/pychrysa.c
@@ -24,6 +24,7 @@
#include "pychrysa.h"
+#include <errno.h>
#include <pygobject.h>
#include <stdio.h>
#include <stdbool.h>
@@ -485,9 +486,7 @@ static bool load_python_plugins(GPluginModule *plugin, GObject *ref)
char *save; /* Sauvegarde pour ré-entrance */
char *path; /* Chemin à fouiller */
DIR *dir; /* Répertoire à parcourir */
- struct dirent entry; /* Elément trouvé */
- struct dirent *next; /* Prochain élément fourni */
- int ret; /* Bilan d'un appel système */
+ struct dirent *entry; /* Elément trouvé */
char *modname; /* Nom du module pour Python */
char *filename; /* Chemin d'accès reconstruit */
GPluginModule *pyplugin; /* Lien vers un grffon Python */
@@ -511,20 +510,31 @@ static bool load_python_plugins(GPluginModule *plugin, GObject *ref)
_("Looking for Python plugins in '%s'..."),
path);
- for (ret = readdir_r(dir, &entry, &next);
- ret == 0 && next != NULL;
- ret = readdir_r(dir, &entry, &next))
+ while (1)
{
- if (entry.d_type != DT_DIR) continue;
- if (entry.d_name[0] == '.') continue;
+ errno = 0;
- modname = strdup(entry.d_name);
+ entry = readdir(dir);
+
+ if (entry == NULL)
+ {
+ if (errno != 0)
+ perror("readdir");
+
+ break;
+
+ }
+
+ if (entry->d_type != DT_DIR) continue;
+ if (entry->d_name[0] == '.') continue;
+
+ modname = strdup(entry->d_name);
modname = stradd(modname, ".");
modname = stradd(modname, "__init__");
filename = strdup(path);
filename = stradd(filename, G_DIR_SEPARATOR_S);
- filename = stradd(filename, entry.d_name);
+ filename = stradd(filename, entry->d_name);
pyplugin = g_python_plugin_new(modname, filename, ref);