[GRASS-SVN] r60400 - grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon

svn_grass at osgeo.org svn_grass at osgeo.org
Wed May 21 20:04:11 PDT 2014


Author: neteler
Date: 2014-05-21 20:04:11 -0700 (Wed, 21 May 2014)
New Revision: 60400

Modified:
   grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.c
Log:
r.li.daemon: fix creation of path to r.li configuration files and output files (portability) (backport of develbr6, r60279)

Modified: grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.c	2014-05-22 03:03:02 UTC (rev 60399)
+++ grass/branches/releasebranch_6_4/raster/r.li/r.li.daemon/daemon.c	2014-05-22 03:04:11 UTC (rev 60400)
@@ -69,15 +69,17 @@
        ######################################################### */
 
     /* strip off leading path if present */
+    char rlipath[GPATH_MAX];
     char testpath[GPATH_MAX];
 
-    sprintf(testpath, "%s%s", G_home(), "/.r.li/history/");
+    sprintf(rlipath, "%s%c%s%c", G_home(), HOST_DIRSEP, ".r.li", HOST_DIRSEP);
+
+    sprintf(testpath, "%s%s%c", rlipath, "history", 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/.r.li/history/%s", G_home(), file);
+    sprintf(pathSetup, "%s%s%c%s", rlipath, "history", HOST_DIRSEP, file);
     G_debug(1, "r.li.daemon pathSetup: [%s]", pathSetup);
     parsed = parseSetup(pathSetup, l, g, raster);
 
@@ -101,25 +103,19 @@
     }
     else {
 	/* text file output */
-	/* check if ~/.r.li/output exists */
-	sprintf(out, "%s/.r.li/", G_home());
-	doneDir = G_mkdir(out);
-	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s/.r.li/ directory"), G_home());
-
 	/* check if ~/.r.li/ exists */
-	sprintf(out, "%s/.r.li/", G_home());
+	sprintf(out, "%s", rlipath);
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s/.r.li/ directory"), G_home());
+	    G_fatal_error(_("Cannot create %s directory"), rlipath);
 
-	/* check if ~/.r.li/output exists */
-	sprintf(out, "%s/.r.li/output", G_home());
+	/* check if ~/.r.li/output/ exists */
+	sprintf(out, "%s%s%c", rlipath, "output", HOST_DIRSEP);
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s/.r.li/output/ directory"),
-			  G_home());
-	sprintf(out, "%s/.r.li/output/%s", G_home(), output);
+	    G_fatal_error(_("Cannot create %s%s%c directory"), rlipath, "output", HOST_DIRSEP);
+
+	sprintf(out, "%s%s%c%s", rlipath, "output", HOST_DIRSEP, output);
 	res = open(out, O_WRONLY | O_CREAT | O_TRUNC, 0644);
     }
     i = 0;



More information about the grass-commit mailing list