diff options
author | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-03-24T17·46+0000 |
---|---|---|
committer | Eelco Dolstra <e.dolstra@tudelft.nl> | 2005-03-24T17·46+0000 |
commit | c6178f0b038097584cbbac970ebdb3772de27763 (patch) | |
tree | f1786c81a1db945ed4f126fc114af62518cc74cd /src/libutil/util.cc | |
parent | d1487d9015222c33680c7727c31e3b499c620610 (diff) |
* Create missing log and temproots directories automatically (reported
by Rob).
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r-- | src/libutil/util.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 27df7a1aaa52..65c3b15397c7 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -271,6 +271,16 @@ Path createTempDir() } +void createDirs(const Path & path) +{ + if (path == "") return; + createDirs(dirOf(path)); + if (!pathExists(path)) + if (mkdir(path.c_str(), 0777) == -1) + throw SysError(format("creating directory `%1%'") % path); +} + + void writeStringToFile(const Path & path, const string & s) { AutoCloseFD fd(open(path.c_str(), |