Sfoglia il codice sorgente

r.li.daemon: fix creation of path to r.li configuration files and output files, before it was working only on unix

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@60220 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 11 anni fa
parent
commit
f0fba34a1f
1 ha cambiato i file con 17 aggiunte e 11 eliminazioni
  1. 17 11
      raster/r.li/r.li.daemon/daemon.c

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

@@ -72,13 +72,15 @@ int calculateIndex(char *file, rli_func *f,
     /* 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 @@ int calculateIndex(char *file, rli_func *f,
     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;