mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-04 22:28:27 +00:00
Allow unique_file to take a mode for file permissions, but default
to user only read/write. Part of rdar://11325849 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156591 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user