瀏覽代碼

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 10 年之前
父節點
當前提交
1cd8a9ef10
共有 6 個文件被更改,包括 26 次插入10 次删除
  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_pid(int);
 void G_temp_element(char *);
+void G__temp_element(char *, int);
 
 /* mkstemp.c */
 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
   $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 {
 	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,7 +101,18 @@ char *G_tempfile_pid(int pid)
  */
 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();
@@ -110,12 +121,10 @@ void G_temp_element(char *element)
 	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);
 }

+ 1 - 1
lib/init/clean_temp.c

@@ -135,7 +135,7 @@ int main(int argc, char *argv[])
 
     /* 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__

+ 7 - 1
lib/init/variables.html

@@ -352,7 +352,13 @@ PERMANENT
   <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>

+ 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) {
         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 {