Pārlūkot izejas kodu

g.tempfile: dry run mode added (don't create a file, just print it's name)
i18n-related fixes


git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46975 15284696-431f-4ddb-bdfa-cd5b030d7da7

Martin Landa 14 gadi atpakaļ
vecāks
revīzija
40a4f4fcea
1 mainītis faili ar 24 papildinājumiem un 16 dzēšanām
  1. 24 16
      general/g.tempfile/main.c

+ 24 - 16
general/g.tempfile/main.c

@@ -4,14 +4,16 @@
  * MODULE:       g.tempfile
  * AUTHOR(S):    Michael Shapiro CERL (original contributor)
  *               Markus Neteler <neteler itc.it>,
- *               Roberto Flor <flor itc.it>, Bernhard Reiter <bernhard intevation.de>, 
- *               Jan-Oliver Wagner <jan intevation.de>
+ *               Roberto Flor <flor itc.it>,
+ *               Bernhard Reiter <bernhard intevation.de>, 
+ *               Jan-Oliver Wagner <jan intevation.de>,
+ *               Martin Landa <landa.martin gmail.com>
  * PURPOSE:      
- * COPYRIGHT:    (C) 1999-2006 by the GRASS Development Team
+ * COPYRIGHT:    (C) 1999-2006, 2011 by the GRASS Development Team
  *
- *               This program is free software under the GNU General Public
- *               License (>=v2). Read the file COPYING that comes with GRASS
- *               for details.
+ *               This program is free software under the GNU General
+ *               Public License (>=v2). Read the file COPYING that
+ *               comes with GRASS for details.
  *
  *****************************************************************************/
 #include <stdlib.h>
@@ -26,36 +28,42 @@ int main(int argc, char *argv[])
 {
     struct GModule *module;
     struct Option *pid;
+    struct Flag *dry_run;
     char *tempfile, *G__tempfile();
     int p;
-
-
+    
     G_gisinit(argv[0]);
 
     module = G_define_module();
     G_add_keyword(_("general"));
-    G_add_keyword(_("map management"));
-    module->description =
-	"Creates a temporary file and prints the file name.";
+    G_add_keyword(_("support"));
+    
+    module->description = _("Creates a temporary file and prints it's file name.");
 
     pid = G_define_option();
     pid->key = "pid";
     pid->type = TYPE_INTEGER;
     pid->required = YES;
-    pid->description = "Process id to use when naming the tempfile";
-
+    pid->description = _("Process id to use when naming the tempfile");
+    
+    dry_run = G_define_flag();
+    dry_run->key = 'd';
+    dry_run->description = _("Dry run - don't create a file, just prints it's file name");
+    
     G_disable_interactive();
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
-
+    
     if (sscanf(pid->answer, "%d", &p) != 1) {
 	G_usage();
 	exit(EXIT_FAILURE);
     }
     tempfile = G__tempfile(p);
-
+    
     /* create tempfile so next run of this program will create a unique name */
-    close(creat(tempfile, 0666));
+    if (!dry_run->answer)
+	close(creat(tempfile, 0666));
     fprintf(stdout, "%s\n", tempfile);
+    
     exit(EXIT_SUCCESS);
 }