Jelajahi Sumber

r.li: use G_config_dir() - see https://trac.osgeo.org/grass/changeset/60220

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60221 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 11 tahun lalu
induk
melakukan
be8a033c24
1 mengubah file dengan 10 tambahan dan 17 penghapusan
  1. 10 17
      raster/r.li/r.li.daemon/daemon.c

+ 10 - 17
raster/r.li/r.li.daemon/daemon.c

@@ -72,15 +72,13 @@ int calculateIndex(char *file, rli_func *f,
     /* strip off leading path if present */
     char testpath[GPATH_MAX];
 
-    sprintf(testpath, "%s%c.grass7%cr.li%c", G_home(), HOST_DIRSEP,
-	    HOST_DIRSEP, HOST_DIRSEP);
+    sprintf(testpath, "%s%c%s%c", G_config_path(), HOST_DIRSEP, "r.li", HOST_DIRSEP);
     if (strncmp(file, testpath, strlen(testpath)) == 0)
 	file += strlen(testpath);
 
     /* TODO: check if this path is portable */
     /* TODO: use G_rc_path() */
-    sprintf(pathSetup, "%s%c.grass7%cr.li%c%s", G_home(), HOST_DIRSEP,
-	    HOST_DIRSEP, HOST_DIRSEP, file);
+    sprintf(pathSetup, "%s%c%s%c%s", G_config_path(), HOST_DIRSEP, "r.li", HOST_DIRSEP, file);
     G_debug(1, "r.li.daemon pathSetup: [%s]", pathSetup);
     parsed = parseSetup(pathSetup, l, g, raster);
 
@@ -103,29 +101,24 @@ int calculateIndex(char *file, rli_func *f,
     else {
 	/* text file output */
 	/* check if ~/.grass7/ exists */
-	sprintf(out, "%s%c.grass7%c", G_home(), HOST_DIRSEP, HOST_DIRSEP);
+        sprintf(out, "%s", G_config_path());
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s%c.grass7%c directory"),
-			  G_home(), HOST_DIRSEP, HOST_DIRSEP);
+	    G_fatal_error(_("Cannot create %s directory"), out);
 
 	/* check if ~/.grass7/r.li/ exists */
-	sprintf(out, "%s%c.grass7%cr.li%c", G_home(), HOST_DIRSEP,
-		HOST_DIRSEP, HOST_DIRSEP);
+	sprintf(out, "%s%c%s%c", G_config_path(), HOST_DIRSEP, "r.li", HOST_DIRSEP);
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s%c.grass7%cr.li%c directory"),
-			  G_home(), HOST_DIRSEP, HOST_DIRSEP, HOST_DIRSEP);
+	    G_fatal_error(_("Cannot create %s directory"), out);
 
 	/* check if ~/.grass7/r.li/output exists */
-	sprintf(out, "%s%c.grass7%cr.li%coutput", G_home(), HOST_DIRSEP,
-		HOST_DIRSEP, HOST_DIRSEP);
+	sprintf(out, "%s%c%s%c%s", G_config_path(), HOST_DIRSEP, "r.li", HOST_DIRSEP, "output");
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s%c.grass7%cr.li%coutput%c directory"),
-			  G_home(), HOST_DIRSEP, HOST_DIRSEP, HOST_DIRSEP, HOST_DIRSEP);
-	sprintf(out, "%s%c.grass7%cr.li%coutput%c%s", G_home(), HOST_DIRSEP,
-		HOST_DIRSEP, HOST_DIRSEP, HOST_DIRSEP, output);
+	    G_fatal_error(_("Cannot create %s directory"), out);
+	sprintf(out, "%s%c%s%c%s%c%s",
+                G_config_path(), HOST_DIRSEP, "r.li", HOST_DIRSEP, "output", HOST_DIRSEP, output);
 	res = open(out, O_WRONLY | O_CREAT | O_TRUNC, 0644);
     }
     i = 0;