[GRASS-SVN] r65436 - in grass/trunk: include/defs lib/gis lib/init lib/vector/Vlib

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Jun 10 12:00:04 PDT 2015


Author: martinl
Date: 2015-06-10 12:00:04 -0700 (Wed, 10 Jun 2015)
New Revision: 65436

Modified:
   grass/trunk/include/defs/gis.h
   grass/trunk/lib/gis/file_name.c
   grass/trunk/lib/gis/tempfile.c
   grass/trunk/lib/init/clean_temp.c
   grass/trunk/lib/init/variables.html
   grass/trunk/lib/vector/Vlib/open.c
Log:
change GRASS_TMPDIR_MAPSET to be accepted only by vector library
       (see https://trac.osgeo.org/grass/ticket/2349#comment:36)


Modified: grass/trunk/include/defs/gis.h
===================================================================
--- grass/trunk/include/defs/gis.h	2015-06-10 18:48:44 UTC (rev 65435)
+++ grass/trunk/include/defs/gis.h	2015-06-10 19:00:04 UTC (rev 65436)
@@ -652,6 +652,7 @@
 char *G_tempfile(void);
 char *G_tempfile_pid(int);
 void G_temp_element(char *);
+void G__temp_element(char *, int);
 
 /* mkstemp.c */
 char *G_mktemp(char *);

Modified: grass/trunk/lib/gis/file_name.c
===================================================================
--- grass/trunk/lib/gis/file_name.c	2015-06-10 18:48:44 UTC (rev 65435)
+++ grass/trunk/lib/gis/file_name.c	2015-06-10 19:00:04 UTC (rev 65436)
@@ -60,7 +60,7 @@
 }
 
 /*!
-  \brief Builds full path names to GIS data files in temporary directory
+  \brief Builds full path names to GIS data files in temporary directory (for internal use only)
 
   By default temporary directory is located
   $LOCATION/$MAPSET/.tmp/$HOSTNAME. If GRASS_TMPDIR_MAPSET is set to

Modified: grass/trunk/lib/gis/tempfile.c
===================================================================
--- grass/trunk/lib/gis/tempfile.c	2015-06-10 18:48:44 UTC (rev 65435)
+++ grass/trunk/lib/gis/tempfile.c	2015-06-10 19:00:04 UTC (rev 65436)
@@ -85,7 +85,7 @@
     do {
 	int uniq = G_counter_next(&unique);
 	sprintf(name, "%d.%d", pid, uniq);
-	G_file_name_tmp(path, element, name, G_mapset());
+	G_file_name(path, element, name, G_mapset());
     }
     while (access(path, F_OK) == 0);
 
@@ -101,8 +101,19 @@
  */
 void G_temp_element(char *element)
 {
-    const char *machine, *env;
+    G__temp_element(element, FALSE);
+}
 
+/*!
+ * \brief Populates element with a path string (internal use only!)
+ *
+ * \param[out] element element name
+ * \param tmp TRUE to use G_make_mapset_element_tmp() instead of G_make_mapset_element()
+ */
+void G__temp_element(char *element, int tmp)
+{
+    const char *machine;
+
     strcpy(element, ".tmp");
     machine = G__machine_name();
     if (machine != NULL && *machine != 0) {
@@ -110,12 +121,10 @@
 	strcat(element, machine);
     }
     
-    env = getenv("GRASS_TMPDIR_MAPSET");
-    if (!env || strcmp(env, "0") != 0)
+    if (!tmp)
         G_make_mapset_element(element);
     else
         G_make_mapset_element_tmp(element);
     
-    G_debug(2, "G_temp_element(): %s (GRASS_TMPDIR_MAPSET=%s)",
-            element, env ? env : "");
+    G_debug(2, "G__temp_element(): %s (tmp=%d)", element, tmp);
 }

Modified: grass/trunk/lib/init/clean_temp.c
===================================================================
--- grass/trunk/lib/init/clean_temp.c	2015-06-10 18:48:44 UTC (rev 65435)
+++ grass/trunk/lib/init/clean_temp.c	2015-06-10 19:00:04 UTC (rev 65436)
@@ -135,7 +135,7 @@
 
     /* Get the mapset temp directory */
     G_temp_element(element);
-    G_file_name_tmp(tmppath, element, "", mapset = G_mapset());
+    G_file_name(tmppath, element, "", mapset = G_mapset());
 
     /* get user id and current time in seconds */
 #ifdef __MINGW32__

Modified: grass/trunk/lib/init/variables.html
===================================================================
--- grass/trunk/lib/init/variables.html	2015-06-10 18:48:44 UTC (rev 65435)
+++ grass/trunk/lib/init/variables.html	2015-06-10 19:00:04 UTC (rev 65436)
@@ -352,7 +352,13 @@
   <tt>$LOCATION/$MAPSET/.tmp/$HOSTNAME</tt>. If GRASS_TMPDIR_MAPSET is
   set to '0', the temporary directory is located in TMPDIR
   (environmental variable defined by the user or GRASS initialization
-  script if not given).</dd>
+  script if not given).
+
+  <p>
+  Important note: This variable is currently used only in vector
+  library. In other words the variable is ignored by raster or
+  raster3d library.
+  </dd>
   
   <dt>TMPDIR, TEMP, TMP</dt>
   <dd>[Various GRASS GIS commands and wxGUI]<br>

Modified: grass/trunk/lib/vector/Vlib/open.c
===================================================================
--- grass/trunk/lib/vector/Vlib/open.c	2015-06-10 18:48:44 UTC (rev 65435)
+++ grass/trunk/lib/vector/Vlib/open.c	2015-06-10 19:00:04 UTC (rev 65436)
@@ -1438,7 +1438,7 @@
 {
     if (Map->temporary) {
         char path_tmp[GPATH_MAX];
-        G_temp_element(path_tmp);
+        G__temp_element(path_tmp, TRUE);
         sprintf(path, "%s/%s/%s", path_tmp, GV_DIRECTORY, Map->name);
     }
     else {



More information about the grass-commit mailing list