Selaa lähdekoodia

d.mon: use always full path for output files (even if using default file name) - https://trac.osgeo.org/grass/ticket/2509

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@63465 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 10 vuotta sitten
vanhempi
commit
182de01864
1 muutettua tiedostoa jossa 19 lisäystä ja 6 poistoa
  1. 19 6
      display/d.mon/start.c

+ 19 - 6
display/d.mon/start.c

@@ -2,6 +2,7 @@
 #include <string.h>
 #include <grass/gis.h>
 #include <grass/spawn.h>
+#include <grass/display.h>
 #include <grass/glocale.h>
 
 #include "proto.h"
@@ -14,11 +15,23 @@ static void start_wx(const char *, const char *, const char *,
 void start(const char *name, const char *output)
 {
     char *env_name, output_path[GPATH_MAX];
+    const char *output_name;
     
-    if (!output)
-	return;
+    if (!output) {
+        if (D_open_driver() != 0)
+            G_fatal_error(_("No graphics device selected. "
+                            "Use d.mon to select graphics device."));
+        output_name = D_get_file();
+        if (!output_name) 
+            return;
+        D_close_driver();
+    }
+    else {
+        output_name = output;
+    }
 
-    if (!strchr(output, HOST_DIRSEP)) { /* relative path */
+        
+    if (!strchr(output_name, HOST_DIRSEP)) { /* relative path */
         char *ptr;
         
         if (!getcwd(output_path, PATH_MAX))
@@ -28,13 +41,13 @@ void start(const char *name, const char *output)
             *(ptr++) = HOST_DIRSEP;
             *(ptr) = '\0';
         }
-        strcat(output_path, output);
+        strcat(output_path, output_name);
         G_message(_("Output file: %s"), output_path);
     }
     else {
-        strcpy(output_path, output); /* already full path */
+        strcpy(output_path, output_name); /* already full path */
     }
-    
+
     env_name = NULL;
     G_asprintf(&env_name, "MONITOR_%s_MAPFILE", G_store_upper(name));
     G_setenv(env_name, output_path);