[GRASS-SVN] r60220 - grass/trunk/raster/r.li/r.li.daemon

svn_grass at osgeo.org svn_grass at osgeo.org
Tue May 13 02:50:33 PDT 2014


Author: lucadelu
Date: 2014-05-13 02:50:33 -0700 (Tue, 13 May 2014)
New Revision: 60220

Modified:
   grass/trunk/raster/r.li/r.li.daemon/daemon.c
Log:
r.li.daemon: fix creation of path to r.li configuration files and output files, before it was working only on unix

Modified: grass/trunk/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/trunk/raster/r.li/r.li.daemon/daemon.c	2014-05-13 08:04:41 UTC (rev 60219)
+++ grass/trunk/raster/r.li/r.li.daemon/daemon.c	2014-05-13 09:50:33 UTC (rev 60220)
@@ -72,13 +72,15 @@
     /* strip off leading path if present */
     char testpath[GPATH_MAX];
 
-    sprintf(testpath, "%s%s", G_home(), "/.grass7/r.li/");
+    sprintf(testpath, "%s%c.grass7%cr.li%c", G_home(), HOST_DIRSEP,
+	    HOST_DIRSEP, 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/.grass7/r.li/%s", G_home(), file);
+    sprintf(pathSetup, "%s%c.grass7%cr.li%c%s", G_home(), HOST_DIRSEP,
+	    HOST_DIRSEP, HOST_DIRSEP, file);
     G_debug(1, "r.li.daemon pathSetup: [%s]", pathSetup);
     parsed = parseSetup(pathSetup, l, g, raster);
 
@@ -101,25 +103,29 @@
     else {
 	/* text file output */
 	/* check if ~/.grass7/ exists */
-	sprintf(out, "%s/.grass7/", G_home());
+	sprintf(out, "%s%c.grass7%c", G_home(), HOST_DIRSEP, HOST_DIRSEP);
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s/.grass7/ directory"), G_home());
+	    G_fatal_error(_("Cannot create %s%c.grass7%c directory"),
+			  G_home(), HOST_DIRSEP, HOST_DIRSEP);
 
 	/* check if ~/.grass7/r.li/ exists */
-	sprintf(out, "%s/.grass7/r.li/", G_home());
+	sprintf(out, "%s%c.grass7%cr.li%c", G_home(), HOST_DIRSEP,
+		HOST_DIRSEP, HOST_DIRSEP);
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s/.grass7/r.li/ directory"),
-			  G_home());
+	    G_fatal_error(_("Cannot create %s%c.grass7%cr.li%c directory"),
+			  G_home(), HOST_DIRSEP, HOST_DIRSEP, HOST_DIRSEP);
 
 	/* check if ~/.grass7/r.li/output exists */
-	sprintf(out, "%s/.grass7/r.li/output", G_home());
+	sprintf(out, "%s%c.grass7%cr.li%coutput", G_home(), HOST_DIRSEP,
+		HOST_DIRSEP, HOST_DIRSEP);
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s/.grass7/r.li/output/ directory"),
-			  G_home());
-	sprintf(out, "%s/.grass7/r.li/output/%s", G_home(), output);
+	    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);
 	res = open(out, O_WRONLY | O_CREAT | O_TRUNC, 0644);
     }
     i = 0;



More information about the grass-commit mailing list