[GRASS5] A GRASS user configuration directory...

Eric G. Miller egm2 at jps.net
Fri Feb 23 02:27:31 EST 2001


I've done a bit of the work to handle a user's configuration directory
in $HOME/.grass.  I don't know if this is something we want to mess with
now, or wait until later.  Basically, I have one callable function
so far: G_rc_path(char *elems, char *item).  It works similar to
the G_element() types of functions, but it does several things.

  1) creates $HOME/.grass if it doesn't exist...
  2) creates subdirectories "elems" of $HOME/.grass as need be, if
     "elems" is not NULL.
  3) Tries hard to make sure all directories are created drwx------
  4) Forbids any element starting with '.'
  4) Forbids any element starting with '/' or containing a '//'
  5) Strips trailing '/' from "elems" if it exists.
  6) Forbids any item (a file) from starting with a "."
  7) Forbids any item from containing a "/"
  8) Makes sure all "elems" are directories.
  9) Nested directories can be specified with elems == "foo/bar/baz"
  10) Allows either "elems" or "item" to be NULL, but not both.  If
      "elems" is NULL, items will live in the "top level". 
  11) Doesn't do any existence or lstat tests on "item".
  12) Returns a "path" which will either be to an existing directory
      (created as needed) or a file, or returns NULL on error.
  12) Works for me... ;)

I still have to change a few assertions to errors, maybe add some
related functions??  Accepting comments...

P.S. I looked at using the G_home() functions.  Argh! It does some
really bad stuff:
    fd = G_popen ("cd ; pwd", "r");

That one is up there with system("more");  Thank you, I prefer "less"!

-- 
Eric G. Miller <egm2 at jps.net>

---------------------------------------- 
If you want to unsubscribe from GRASS Development Team mailing list write to:
minordomo at geog.uni-hannover.de with
subject 'unsubscribe grass5'



More information about the grass-dev mailing list