diff options
author | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 05:42:11 +0000 |
---|---|---|
committer | Michael J. Spencer <bigcheesegs@gmail.com> | 2010-12-03 05:42:11 +0000 |
commit | b83769f36afe5221ca6aa7741561801836a179cb (patch) | |
tree | b59e4264aae3529bdd995d3663f9229188a5251f /lib/Support/Unix | |
parent | 2df042cb32ecb8d2e1d499dfa27d5074c8b40e13 (diff) |
Support/FileSystem: Add create_director{y,ies} implementations.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120790 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Unix')
-rw-r--r-- | lib/Support/Unix/PathV2.inc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Support/Unix/PathV2.inc b/lib/Support/Unix/PathV2.inc index 1368a82658..fc0d4a09a7 100644 --- a/lib/Support/Unix/PathV2.inc +++ b/lib/Support/Unix/PathV2.inc @@ -146,6 +146,20 @@ error_code copy_file(const Twine &from, const Twine &to, copy_option copt) { return make_error_code(errc::success); } +error_code create_directory(const Twine &path, bool &existed) { + SmallString<128> path_storage; + StringRef p = path.toNullTerminatedStringRef(path_storage); + + if (::mkdir(p.begin(), 0700) == -1) { + if (errno != EEXIST) + return error_code(errno, system_category()); + existed = true; + } else + existed = false; + + return make_error_code(errc::success); +} + error_code exists(const Twine &path, bool &result) { SmallString<128> path_storage; StringRef p = path.toNullTerminatedStringRef(path_storage); |