Parcourir la source

change GRASS_TMPDIR_MAPSET to be accepted only by vector library
(see https://trac.osgeo.org/grass/ticket/2349#comment:36)


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

Martin Landa il y a 10 ans
Parent
commit
1cd8a9ef10
6 fichiers modifiés avec 26 ajouts et 10 suppressions
  1. 1 0
      include/defs/gis.h
  2. 1 1
      lib/gis/file_name.c
  3. 15 6
      lib/gis/tempfile.c
  4. 1 1
      lib/init/clean_temp.c
  5. 7 1
      lib/init/variables.html
  6. 1 1
      lib/vector/Vlib/open.c

+ 1 - 0
include/defs/gis.h

@@ -652,6 +652,7 @@ void G_init_tempfile(void);
 char *G_tempfile(void);
 char *G_tempfile(void);
 char *G_tempfile_pid(int);
 char *G_tempfile_pid(int);
 void G_temp_element(char *);
 void G_temp_element(char *);
+void G__temp_element(char *, int);
 
 
 /* mkstemp.c */
 /* mkstemp.c */
 char *G_mktemp(char *);
 char *G_mktemp(char *);

+ 1 - 1
lib/gis/file_name.c

@@ -60,7 +60,7 @@ char *G_file_name_misc(char *path,
 }
 }
 
 
 /*!
 /*!
-  \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
   By default temporary directory is located
   $LOCATION/$MAPSET/.tmp/$HOSTNAME. If GRASS_TMPDIR_MAPSET is set to
   $LOCATION/$MAPSET/.tmp/$HOSTNAME. If GRASS_TMPDIR_MAPSET is set to

+ 15 - 6
lib/gis/tempfile.c

@@ -85,7 +85,7 @@ char *G_tempfile_pid(int pid)
     do {
     do {
 	int uniq = G_counter_next(&unique);
 	int uniq = G_counter_next(&unique);
 	sprintf(name, "%d.%d", pid, uniq);
 	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);
     while (access(path, F_OK) == 0);
 
 
@@ -101,7 +101,18 @@ char *G_tempfile_pid(int pid)
  */
  */
 void G_temp_element(char *element)
 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");
     strcpy(element, ".tmp");
     machine = G__machine_name();
     machine = G__machine_name();
@@ -110,12 +121,10 @@ void G_temp_element(char *element)
 	strcat(element, machine);
 	strcat(element, machine);
     }
     }
     
     
-    env = getenv("GRASS_TMPDIR_MAPSET");
-    if (!env || strcmp(env, "0") != 0)
+    if (!tmp)
         G_make_mapset_element(element);
         G_make_mapset_element(element);
     else
     else
         G_make_mapset_element_tmp(element);
         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);
 }
 }

+ 1 - 1
lib/init/clean_temp.c

@@ -135,7 +135,7 @@ int main(int argc, char *argv[])
 
 
     /* Get the mapset temp directory */
     /* Get the mapset temp directory */
     G_temp_element(element);
     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 */
     /* get user id and current time in seconds */
 #ifdef __MINGW32__
 #ifdef __MINGW32__

+ 7 - 1
lib/init/variables.html

@@ -352,7 +352,13 @@ PERMANENT
   <tt>$LOCATION/$MAPSET/.tmp/$HOSTNAME</tt>. If GRASS_TMPDIR_MAPSET is
   <tt>$LOCATION/$MAPSET/.tmp/$HOSTNAME</tt>. If GRASS_TMPDIR_MAPSET is
   set to '0', the temporary directory is located in TMPDIR
   set to '0', the temporary directory is located in TMPDIR
   (environmental variable defined by the user or GRASS initialization
   (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>
   <dt>TMPDIR, TEMP, TMP</dt>
   <dd>[Various GRASS GIS commands and wxGUI]<br>
   <dd>[Various GRASS GIS commands and wxGUI]<br>

+ 1 - 1
lib/vector/Vlib/open.c

@@ -1438,7 +1438,7 @@ char *Vect__get_path(char *path, const struct Map_info *Map)
 {
 {
     if (Map->temporary) {
     if (Map->temporary) {
         char path_tmp[GPATH_MAX];
         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);
         sprintf(path, "%s/%s/%s", path_tmp, GV_DIRECTORY, Map->name);
     }
     }
     else {
     else {