diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-08 16:16:51 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-08 16:16:51 +0000 |
commit | bb625bb2f49a7716efaad5d70e51c949cab666dc (patch) | |
tree | 025c0b9afdec427c5928aded99924badbf583839 /llvm/tools/llvm-ar/llvm-ar.cpp | |
parent | 77c9fe5c0547b26acdbd0da9590f6b8d588d1ca1 (diff) | |
download | bcm5719-llvm-bb625bb2f49a7716efaad5d70e51c949cab666dc.tar.gz bcm5719-llvm-bb625bb2f49a7716efaad5d70e51c949cab666dc.zip |
Create files with the correct permission instead of changing it afterwards.
No intended functionality change.
llvm-svn: 185832
Diffstat (limited to 'llvm/tools/llvm-ar/llvm-ar.cpp')
-rw-r--r-- | llvm/tools/llvm-ar/llvm-ar.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp index a9297eb0575..bf9447bccf9 100644 --- a/llvm/tools/llvm-ar/llvm-ar.cpp +++ b/llvm/tools/llvm-ar/llvm-ar.cpp @@ -404,7 +404,10 @@ doExtract(std::string* ErrMsg) { OpenFlags |= O_BINARY; #endif - int FD = open(I->getPath().str().c_str(), OpenFlags, 0664); + // Retain the original mode. + sys::fs::perms Mode = sys::fs::perms(I->getMode()); + + int FD = open(I->getPath().str().c_str(), OpenFlags, Mode); if (FD < 0) return true; @@ -419,17 +422,11 @@ doExtract(std::string* ErrMsg) { file.write(data, len); } - // Retain the original mode. - sys::fs::perms Mode = sys::fs::perms(I->getMode()); - // FIXME: at least on posix we should be able to reuse FD (fchmod). - error_code EC = sys::fs::permissions(I->getPath(), Mode); - if (EC) - fail(EC.message()); - // If we're supposed to retain the original modification times, etc. do so // now. if (OriginalDates) { - EC = sys::fs::setLastModificationAndAccessTime(FD, I->getModTime()); + error_code EC = + sys::fs::setLastModificationAndAccessTime(FD, I->getModTime()); if (EC) fail(EC.message()); } |