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

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Dec 9 11:19:02 PST 2014


Author: martinl
Date: 2014-12-09 11:19:02 -0800 (Tue, 09 Dec 2014)
New Revision: 63457

Modified:
   grass/trunk/display/d.mon/start.c
Log:
d.mon: output - rely always on full path

Modified: grass/trunk/display/d.mon/start.c
===================================================================
--- grass/trunk/display/d.mon/start.c	2014-12-09 18:51:22 UTC (rev 63456)
+++ grass/trunk/display/d.mon/start.c	2014-12-09 19:19:02 UTC (rev 63457)
@@ -13,14 +13,31 @@
 /* start file-based monitor */
 void start(const char *name, const char *output)
 {
-    char *env_name;
-
+    char *env_name, output_path[GPATH_MAX];
+    
     if (!output)
 	return;
 
+    if (!strchr(output, HOST_DIRSEP)) { /* relative path */
+        char *ptr;
+        
+        if (!getcwd(output_path, PATH_MAX))
+            G_fatal_error(_("Unable to get current working directory"));
+        ptr = output_path + strlen(output_path) - 1;
+        if (*(ptr++) != HOST_DIRSEP) {
+            *(ptr++) = HOST_DIRSEP;
+            *(ptr) = '\0';
+        }
+        strcat(output_path, output);
+        G_message(_("Output file: %s"), output_path);
+    }
+    else {
+        strcpy(output_path, output); /* already full path */
+    }
+    
     env_name = NULL;
     G_asprintf(&env_name, "MONITOR_%s_MAPFILE", G_store_upper(name));
-    G_setenv(env_name, output);
+    G_setenv(env_name, output_path);
 }
 
 /* start wxGUI display monitor */



More information about the grass-commit mailing list