[GRASS-SVN] r64503 - grass/trunk/display/d.mon

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Feb 8 01:34:02 PST 2015


Author: martinl
Date: 2015-02-08 01:34:02 -0800 (Sun, 08 Feb 2015)
New Revision: 64503

Modified:
   grass/trunk/display/d.mon/list.c
Log:
d.mon: fix list_mons() on Windows (dp->d_type)


Modified: grass/trunk/display/d.mon/list.c
===================================================================
--- grass/trunk/display/d.mon/list.c	2015-02-07 22:30:52 UTC (rev 64502)
+++ grass/trunk/display/d.mon/list.c	2015-02-08 09:34:02 UTC (rev 64503)
@@ -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 @@
     char *mon_path;
     struct dirent *dp;
     DIR *dirp;
-
+    struct stat s;
+    
     *list = NULL;
     *n    = 0;
     
@@ -46,10 +48,11 @@
     
     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 @@
         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, '.');



More information about the grass-commit mailing list