summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Unix/PathV2.inc
diff options
context:
space:
mode:
authorEric Christopher <echristo@apple.com>2012-05-11 00:07:44 +0000
committerEric Christopher <echristo@apple.com>2012-05-11 00:07:44 +0000
commitb6148ed72cfdc6a2acf584631472cd1257ed1bb6 (patch)
treebf5a691e28ef2bd97a322855427edc8bc2ac2e83 /llvm/lib/Support/Unix/PathV2.inc
parent8244b1dc7e0ed6dcc5fe6192408e48985cbffe7c (diff)
downloadbcm5719-llvm-b6148ed72cfdc6a2acf584631472cd1257ed1bb6.tar.gz
bcm5719-llvm-b6148ed72cfdc6a2acf584631472cd1257ed1bb6.zip
Allow unique_file to take a mode for file permissions, but default
to user only read/write. Part of rdar://11325849 llvm-svn: 156591
Diffstat (limited to 'llvm/lib/Support/Unix/PathV2.inc')
-rw-r--r--llvm/lib/Support/Unix/PathV2.inc7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Support/Unix/PathV2.inc b/llvm/lib/Support/Unix/PathV2.inc
index 3446c28e06d..a7007cd6974 100644
--- a/llvm/lib/Support/Unix/PathV2.inc
+++ b/llvm/lib/Support/Unix/PathV2.inc
@@ -347,9 +347,10 @@ error_code status(const Twine &path, file_status &result) {
return error_code::success();
}
+// Since this is most often used for temporary files, mode defaults to 0600.
error_code unique_file(const Twine &model, int &result_fd,
- SmallVectorImpl<char> &result_path,
- bool makeAbsolute) {
+ SmallVectorImpl<char> &result_path,
+ bool makeAbsolute, unsigned mode) {
SmallString<128> Model;
model.toVector(Model);
// Null terminate.
@@ -379,7 +380,7 @@ retry_random_path:
// Try to open + create the file.
rety_open_create:
- int RandomFD = ::open(RandomPath.c_str(), O_RDWR | O_CREAT | O_EXCL, 0600);
+ int RandomFD = ::open(RandomPath.c_str(), O_RDWR | O_CREAT | O_EXCL, mode);
if (RandomFD == -1) {
// If the file existed, try again, otherwise, error.
if (errno == errc::file_exists)
OpenPOWER on IntegriCloud