diff options
author | Frederic Riss <friss@apple.com> | 2015-08-06 21:04:55 +0000 |
---|---|---|
committer | Frederic Riss <friss@apple.com> | 2015-08-06 21:04:55 +0000 |
commit | 6b9396c07054f0fbeec730d662ca76d111a2a46c (patch) | |
tree | 2551dfa167c60cb56d4746d6348807e97407caed /llvm/lib/Support | |
parent | fc573f33f639979ea4483954584d1ce18fb684bd (diff) | |
download | bcm5719-llvm-6b9396c07054f0fbeec730d662ca76d111a2a46c.tar.gz bcm5719-llvm-6b9396c07054f0fbeec730d662ca76d111a2a46c.zip |
Thread premissions through sys::fs::create_director{y|ies}
llvm-svn: 244268
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/Path.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 5 | ||||
-rw-r--r-- | llvm/lib/Support/Windows/Path.inc | 3 |
3 files changed, 10 insertions, 7 deletions
diff --git a/llvm/lib/Support/Path.cpp b/llvm/lib/Support/Path.cpp index 985cdbf7432..54daf24daba 100644 --- a/llvm/lib/Support/Path.cpp +++ b/llvm/lib/Support/Path.cpp @@ -785,12 +785,13 @@ std::error_code make_absolute(SmallVectorImpl<char> &path) { "occurred above!"); } -std::error_code create_directories(const Twine &Path, bool IgnoreExisting) { +std::error_code create_directories(const Twine &Path, bool IgnoreExisting, + perms Perms) { SmallString<128> PathStorage; StringRef P = Path.toStringRef(PathStorage); // Be optimistic and try to create the directory - std::error_code EC = create_directory(P, IgnoreExisting); + std::error_code EC = create_directory(P, IgnoreExisting, Perms); // If we succeeded, or had any error other than the parent not existing, just // return it. if (EC != errc::no_such_file_or_directory) @@ -802,10 +803,10 @@ std::error_code create_directories(const Twine &Path, bool IgnoreExisting) { if (Parent.empty()) return EC; - if ((EC = create_directories(Parent))) + if ((EC = create_directories(Parent, IgnoreExisting, Perms))) return EC; - return create_directory(P, IgnoreExisting); + return create_directory(P, IgnoreExisting, Perms); } std::error_code copy_file(const Twine &From, const Twine &To) { diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 973d010dcac..a77efcca8f5 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -219,11 +219,12 @@ std::error_code current_path(SmallVectorImpl<char> &result) { return std::error_code(); } -std::error_code create_directory(const Twine &path, bool IgnoreExisting) { +std::error_code create_directory(const Twine &path, bool IgnoreExisting, + perms Perms) { SmallString<128> path_storage; StringRef p = path.toNullTerminatedStringRef(path_storage); - if (::mkdir(p.begin(), S_IRWXU | S_IRWXG) == -1) { + if (::mkdir(p.begin(), Perms) == -1) { if (errno != EEXIST || !IgnoreExisting) return std::error_code(errno, std::generic_category()); } diff --git a/llvm/lib/Support/Windows/Path.inc b/llvm/lib/Support/Windows/Path.inc index 72da7c5fec3..3033149980c 100644 --- a/llvm/lib/Support/Windows/Path.inc +++ b/llvm/lib/Support/Windows/Path.inc @@ -182,7 +182,8 @@ std::error_code current_path(SmallVectorImpl<char> &result) { return UTF16ToUTF8(cur_path.begin(), cur_path.size(), result); } -std::error_code create_directory(const Twine &path, bool IgnoreExisting) { +std::error_code create_directory(const Twine &path, bool IgnoreExisting, + perms Perms) { SmallVector<wchar_t, 128> path_utf16; if (std::error_code ec = widenPath(path, path_utf16)) |