summaryrefslogtreecommitdiffabout
path: root/src/eyetil.cc
Unidiff
Diffstat (limited to 'src/eyetil.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--src/eyetil.cc16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/eyetil.cc b/src/eyetil.cc
index d00c2ee..2fbd687 100644
--- a/src/eyetil.cc
+++ b/src/eyetil.cc
@@ -1,2 +1,3 @@
1#include <stdlib.h> 1#include <stdlib.h>
2#include <sys/stat.h>
2#include <syslog.h> 3#include <syslog.h>
@@ -53,3 +54,18 @@ binary_t binary_t::md5() const {
53 54
55static void make_path_for_template(const std::string& p,mode_t m) {
56 struct stat st;
57 std::string pp;
58 for(std::string::size_type sl=p.find('/',1);
59 sl!=std::string::npos;
60 sl=p.find('/',sl+1)) {
61 if(stat( (pp=p.substr(0,sl)).c_str() ,&st)
62 || !S_ISDIR(st.st_mode)) {
63 if(mkdir(pp.c_str(),m))
64 throw std::runtime_error("failed to mkdir()");
65 }
66 }
67}
68
54tmpdir_t::tmpdir_t(const std::string& dt) : dir(dt) { 69tmpdir_t::tmpdir_t(const std::string& dt) : dir(dt) {
70 make_path_for_template(dt,0777);
55 if(!mkdtemp((char*)dir.data())) 71 if(!mkdtemp((char*)dir.data()))