mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-19 18:25:31 +00:00
Create files with the correct permission instead of changing it afterwards.
Not intended functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185830 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
19d2b78978
commit
73e97d0f48
@ -62,11 +62,16 @@ error_code FileOutputBuffer::create(StringRef FilePath,
|
|||||||
if (EC)
|
if (EC)
|
||||||
return EC;
|
return EC;
|
||||||
|
|
||||||
|
unsigned Mode = sys::fs::all_read | sys::fs::all_write;
|
||||||
|
// If requested, make the output file executable.
|
||||||
|
if (Flags & F_executable)
|
||||||
|
Mode |= sys::fs::all_exe;
|
||||||
|
|
||||||
// Create new file in same directory but with random name.
|
// Create new file in same directory but with random name.
|
||||||
SmallString<128> TempFilePath;
|
SmallString<128> TempFilePath;
|
||||||
int FD;
|
int FD;
|
||||||
EC = sys::fs::createUniqueFile(Twine(FilePath) + ".tmp%%%%%%%",
|
EC = sys::fs::createUniqueFile(Twine(FilePath) + ".tmp%%%%%%%", FD,
|
||||||
FD, TempFilePath);
|
TempFilePath, Mode);
|
||||||
if (EC)
|
if (EC)
|
||||||
return EC;
|
return EC;
|
||||||
|
|
||||||
@ -75,26 +80,6 @@ error_code FileOutputBuffer::create(StringRef FilePath,
|
|||||||
if (EC)
|
if (EC)
|
||||||
return EC;
|
return EC;
|
||||||
|
|
||||||
// If requested, make the output file executable.
|
|
||||||
if ( Flags & F_executable ) {
|
|
||||||
sys::fs::file_status Stat2;
|
|
||||||
EC = sys::fs::status(Twine(TempFilePath), Stat2);
|
|
||||||
if (EC)
|
|
||||||
return EC;
|
|
||||||
|
|
||||||
sys::fs::perms new_perms = Stat2.permissions();
|
|
||||||
if ( new_perms & sys::fs::owner_read )
|
|
||||||
new_perms |= sys::fs::owner_exe;
|
|
||||||
if ( new_perms & sys::fs::group_read )
|
|
||||||
new_perms |= sys::fs::group_exe;
|
|
||||||
if ( new_perms & sys::fs::others_read )
|
|
||||||
new_perms |= sys::fs::others_exe;
|
|
||||||
new_perms |= sys::fs::add_perms;
|
|
||||||
EC = sys::fs::permissions(Twine(TempFilePath), new_perms);
|
|
||||||
if (EC)
|
|
||||||
return EC;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result.reset(new FileOutputBuffer(MappedFile.get(), FilePath, TempFilePath));
|
Result.reset(new FileOutputBuffer(MappedFile.get(), FilePath, TempFilePath));
|
||||||
if (Result)
|
if (Result)
|
||||||
MappedFile.take();
|
MappedFile.take();
|
||||||
|
Loading…
Reference in New Issue
Block a user