diff options
author | Evan Martin <martine@danga.com> | 2012-08-07 20:58:55 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2012-08-07 21:03:00 (GMT) |
commit | cc222d3f6ba769fd800b1dfdb1699fbb84516c7b (patch) | |
tree | 99f395a2f120ffbdd1d1390c8e5d6205d346354f /src/disk_interface.cc | |
parent | 645165bca247558f94d5f47cf7795c463e81d83a (diff) | |
download | Ninja-cc222d3f6ba769fd800b1dfdb1699fbb84516c7b.zip Ninja-cc222d3f6ba769fd800b1dfdb1699fbb84516c7b.tar.gz Ninja-cc222d3f6ba769fd800b1dfdb1699fbb84516c7b.tar.bz2 |
use DiskInterface to create the build directory
Fixes issue #392 (didn't handle creating nested build dirs right).
Moves MakeDir out of util.h; all code should go through
DiskInterface to simplify testing. Moves ownership of the
DiskInterface into the client of the Builder, which also allows
removing some code that reached inside the object as well as
a minor leak.
Diffstat (limited to 'src/disk_interface.cc')
-rw-r--r-- | src/disk_interface.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/disk_interface.cc b/src/disk_interface.cc index 74f33c4..515ff59 100644 --- a/src/disk_interface.cc +++ b/src/disk_interface.cc @@ -18,9 +18,11 @@ #include <stdio.h> #include <string.h> #include <sys/stat.h> +#include <sys/types.h> #ifdef _WIN32 #include <windows.h> +#include <direct.h> // _mkdir #endif #include "util.h" @@ -42,6 +44,14 @@ string DirName(const string& path) { return path.substr(0, slash_pos); } +int MakeDir(const string& path) { +#ifdef _WIN32 + return _mkdir(path.c_str()); +#else + return mkdir(path.c_str(), 0777); +#endif +} + } // namespace // DiskInterface --------------------------------------------------------------- |