[GRASS-SVN] r38760 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Aug 17 01:31:09 EDT 2009


Author: hamish
Date: 2009-08-17 01:31:08 -0400 (Mon, 17 Aug 2009)
New Revision: 38760

Modified:
   grass/trunk/lib/gis/home.c
Log:
crude beginnings of a G_rc_path() fn

Modified: grass/trunk/lib/gis/home.c
===================================================================
--- grass/trunk/lib/gis/home.c	2009-08-17 04:47:26 UTC (rev 38759)
+++ grass/trunk/lib/gis/home.c	2009-08-17 05:31:08 UTC (rev 38760)
@@ -33,7 +33,8 @@
 	return home;
 
     G_fatal_error(_("Unable to determine user's home directory"));
-    
+
+    /* why return NULL when we've already exit(1)'d with G_fatal_error() ?? */
     return NULL;
 }
 
@@ -77,3 +78,41 @@
     G_initialize_done(&initialized);
     return home;
 }
+
+
+#ifdef TODO
+#include <stdio.h>
+#define RCDIR ".grass7"
+
+/*!
+ * \brief Get user's .grass/ config path directory
+ *
+ * Returns a pointer to a string which is the full path name of the
+ * user's .grass/ config directory in their home directory.
+ *
+ * The path is not guaranteed to exist.
+(should it be?  see possible TODO below)
+ *
+ * \return pointer to string
+ * \return NULL on error
+ */
+const char *G_rc_path(void)
+{
+/* choose better name for fn? */
+/* HB: making a complete bollocks of this, but to express the idea... */
+    const char *rcpath = 0;
+
+    sprintf(rcpath, "%s/%s", G_home(), RCDIR);
+
+#ifdef POSSIBILITY
+    /* create it if it doesn't exist */
+#include <errno.h>
+    int ret;
+    ret = G_mkdir(rcpath);
+    if (ret == -1 && errno != EEXIST)
+	G_fatal_error(_("Cannot create directory [%s]"), rcpath);
+#endif
+
+    return G_store(rcpath);
+}
+#endif



More information about the grass-commit mailing list