[GRASS-SVN] r46975 - grass/trunk/general/g.tempfile
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Jul 5 05:58:48 EDT 2011
Author: martinl
Date: 2011-07-05 02:58:48 -0700 (Tue, 05 Jul 2011)
New Revision: 46975
Modified:
grass/trunk/general/g.tempfile/main.c
Log:
g.tempfile: dry run mode added (don't create a file, just print it's name)
i18n-related fixes
Modified: grass/trunk/general/g.tempfile/main.c
===================================================================
--- grass/trunk/general/g.tempfile/main.c 2011-07-05 09:07:12 UTC (rev 46974)
+++ grass/trunk/general/g.tempfile/main.c 2011-07-05 09:58:48 UTC (rev 46975)
@@ -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 @@
{
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);
}
More information about the grass-commit
mailing list