rohrpost

A commandline mail client to change the world as we see it.
git clone git://r-36.net/rohrpost
Log | Files | Refs | LICENSE

commit 04f3d98fbe666032554a5fc6d7437962dd8c7b8a
parent a7a575555390e37e68dc6249fa0b3881657e77d0
Author: Christoph Lohmann <20h@r-36.net>
Date:   Wed, 26 Dec 2012 00:14:44 +0100

Adding user friendly error messages for configuration problems.

Diffstat:
path.c | 39++++++++++++++++++++++++++++++++++++++-
1 file changed, 38 insertions(+), 1 deletion(-)

diff --git a/path.c b/path.c @@ -83,12 +83,49 @@ path_mkrppath(char *rppath) char * path_mkbasepath(char *cfgn) { - char *path, *rpath; + char *path, *rpath, *cwd; + struct stat sbuf; + + cwd = getcwd(NULL, 0); + if (cwd == NULL) + edie("getcwd"); path = path_mkrppath(NULL); + if (chdir(path) < 0) + edie("chdir"); + if (stat("default", &sbuf) < 0) { + if (cfgn == NULL || !strcmp(cfgn, "default")) { + die("You are trying to create a 'default'" + " configuration while no other configuration" + " exists." + " Please use _rppath -ic somecfg_ to" + " initialize the configuration 'somecfg' and" + " make it the default using _rpcfg -e" + " somecfg_. Then this error message" + " disappears.\n"); + } + } else { + if (!S_ISLNK(sbuf.st_mode)) { + die("There seems to be some 'default' configuration" + " folder. This should be a symlink. Please go" + " to '%s' and check this. If no other folder" + " exists, it might help to run" + " _mv default somecfg_ and _rpcfg -e" + " somecfg_. The last command will create the" + " symlink to 'default' and this error message" + " disappears. If nothing helps, remove the" + " 'default' directory and reinitialize your" + " configuration using a different name.\n", + path); + } + } + rpath = path_chkmkdir(path, (cfgn)? cfgn : "default", -1); free(path); + if (chdir(cwd) < 0) + edie("chdir"); + return rpath; }