summaryrefslogtreecommitdiff
path: root/tools/libltgrey.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/libltgrey.c')
-rw-r--r--tools/libltgrey.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/tools/libltgrey.c b/tools/libltgrey.c
index 7104c69..9b02642 100644
--- a/tools/libltgrey.c
+++ b/tools/libltgrey.c
@@ -126,28 +126,36 @@ void whatsit::update(const string msg, const timeval new_mod,
}
#endif
-int whatsit::maybe_mkdir(const string somedir, const string msg){
+int whatsit::maybe_mkdir(const string subdir, const string msg){
// see if our directory exists:
+ string mydir = parent_dir;
+ if (subdir != ".") {
+ mydir += "/" + subdir;
+ }
struct stat dirstat;
- int rslt = stat(somedir.c_str(), &dirstat);
+ int rslt = stat(mydir.c_str(), &dirstat);
if (rslt != 0){
if (errno != ENOENT) {
cerr << progid << " stat failed for "
<< msg
- << " '" << somedir << "' : ";
+ << " '" << mydir << "' : ";
perror(0);
+ return(ex_syserr);
}
- rslt = mkdir(somedir.c_str(), 0755);
+ /* else it simply does not exist */
+ rslt = mkdir(mydir.c_str(), 0755);
if (rslt != 0) {
cerr << progid
- << "uid " << getuid()
+ << " uid " << getuid()
+ << " euid " << geteuid()
<< " mkdir failed for "
<< msg
- << "' " << somedir << "' : ";
+ << " '" << mydir << "' : ";
perror(0);
return(ex_syserr);
}
}
+ // here if stat succeeded
return 0;
}