diff options
author | John Denker <jsd@av8n.com> | 2012-07-31 15:00:19 -0700 |
---|---|---|
committer | John Denker <jsd@av8n.com> | 2012-07-31 17:48:52 -0700 |
commit | 4ed0a7a5212d83029d52ef4104b13cb48e9dd41f (patch) | |
tree | ecc73855dffa21c1fb511c88c70365e2d8c8f9d3 /tools/libltgrey.c | |
parent | efb6301f794cc272173fa09ad83293ad3aa79ad4 (diff) |
ltgrey will attempt to create its working directories
Diffstat (limited to 'tools/libltgrey.c')
-rw-r--r-- | tools/libltgrey.c | 20 |
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; } |