[GRASS-SVN] r60279 - grass/branches/develbranch_6/raster/r.li/r.li.daemon
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri May 16 14:13:07 PDT 2014
Author: neteler
Date: 2014-05-16 14:13:06 -0700 (Fri, 16 May 2014)
New Revision: 60279
Modified:
grass/branches/develbranch_6/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 trunk r60220, r60221, r60278)
Modified: grass/branches/develbranch_6/raster/r.li/r.li.daemon/daemon.c
===================================================================
--- grass/branches/develbranch_6/raster/r.li/r.li.daemon/daemon.c 2014-05-16 21:08:57 UTC (rev 60278)
+++ grass/branches/develbranch_6/raster/r.li/r.li.daemon/daemon.c 2014-05-16 21:13:06 UTC (rev 60279)
@@ -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