From c6178f0b038097584cbbac970ebdb3772de27763 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 24 Mar 2005 17:46:38 +0000 Subject: * Create missing log and temproots directories automatically (reported by Rob). --- src/libutil/util.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/libutil/util.cc') 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(), -- cgit 1.4.1