Forráskód Böngészése

use G_home(), output text file as umask 0644 (merge from devbr6)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@38762 15284696-431f-4ddb-bdfa-cd5b030d7da7
Hamish Bowman 16 éve
szülő
commit
ba5039d435
1 módosított fájl, 20 hozzáadás és 11 törlés
  1. 20 11
      raster/r.li/r.li.daemon/daemon.c

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

@@ -102,8 +102,9 @@ int calculateIndex(char *file, int f(int, char **, area_des, double *),
        ######################################################### */
 
     /* TODO: check if this path is portable */
-    sprintf(pathSetup, "%s/.grass7/r.li/%s", getenv("HOME"), file);
-    G_debug(1, "r.li.daemon pathSetup: %s", pathSetup);
+/* TODO: use G_rc_path() */
+    sprintf(pathSetup, "%s/.grass7/r.li/%s", G_home(), file);
+    G_debug(1, "r.li.daemon pathSetup: [%s]", pathSetup);
     parsed = parseSetup(pathSetup, l, g, raster);
 
     /*########################################################
@@ -124,20 +125,28 @@ int calculateIndex(char *file, int f(int, char **, area_des, double *),
 	    G_fatal_error(_("Cannot create random access file"));
     }
     else {
-	/*check if ~/.r.li/output exist */
-	sprintf(out, "%s/.r.li/", getenv("HOME"));
+	/* check if ~/.grass7/ exists */
+	sprintf(out, "%s/.grass7/", G_home());
+	doneDir = G_mkdir(out);
+	if (doneDir == -1 && errno != EEXIST)
+	    G_fatal_error(_("Cannot create %s/.grass7/ directory"),
+			  G_home());
 
+	/* check if ~/.grass7/r.li/ exists */
+	sprintf(out, "%s/.grass7/r.li/", G_home());
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s/.r.li/ directory"),
-			  getenv("HOME"));
-	sprintf(out, "%s/.r.li/output", getenv("HOME"));
+	    G_fatal_error(_("Cannot create %s/.grass7/r.li/ directory"),
+			  G_home());
+
+	/* check if ~/.grass7/r.li/output exists */
+	sprintf(out, "%s/.grass7/r.li/output", G_home());
 	doneDir = G_mkdir(out);
 	if (doneDir == -1 && errno != EEXIST)
-	    G_fatal_error(_("Cannot create %s/.r.li/output/ directory"),
-			  getenv("HOME"));
-	sprintf(out, "%s/.r.li/output/%s", getenv("HOME"), output);
-	res = open(out, O_WRONLY | O_CREAT | O_TRUNC, 0755);
+	    G_fatal_error(_("Cannot create %s/.grass7/r.li/output/ directory"),
+			  G_home());
+	sprintf(out, "%s/.grass7/r.li/output/%s", G_home(), output);
+	res = open(out, O_WRONLY | O_CREAT | O_TRUNC, 0644);
     }
     i = 0;