Просмотр исходного кода

d.mon: fix list_mons() on Windows (dp->d_type)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@64503 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 лет назад
Родитель
Сommit
e160761978
1 измененных файлов с 7 добавлено и 4 удалено
  1. 7 4
      display/d.mon/list.c

+ 7 - 4
display/d.mon/list.c

@@ -1,6 +1,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <dirent.h>
+#include <sys/stat.h>
 
 #include <grass/gis.h>
 #include <grass/glocale.h>
@@ -36,7 +37,8 @@ void list_mon(char ***list, int *n)
     char *mon_path;
     struct dirent *dp;
     DIR *dirp;
-
+    struct stat s;
+    
     *list = NULL;
     *n    = 0;
     
@@ -46,10 +48,11 @@ void list_mon(char ***list, int *n)
     
     if (!dirp)
         return;
-    
+
     while ((dp = readdir(dirp)) != NULL) {
         *list = G_realloc(*list, (*n + 1) * sizeof(char *));
-        if (!dp->d_name || dp->d_name[0] == '.' || dp->d_type != DT_DIR)
+        stat(dp->d_name, &s);
+        if (!dp->d_name || dp->d_name[0] == '.' || !S_ISDIR(s.st_mode))
             continue;
         (*list)[*n] = dp->d_name;
         (*n)++;
@@ -133,7 +136,7 @@ void list_files(const char *name, FILE *fd_out)
         G_fatal_error(_("No support files found for monitor <%s>"), name);
 
     while ((dp = readdir(dirp)) != NULL) {
-        if (!dp->d_name || dp->d_type != DT_REG)
+        if (!dp->d_name || dp->d_name[0] == '.')
             continue;
         
         p = strrchr(dp->d_name, '.');