[llvm] r185832 - Create files with the correct permission instead of changing it afterwards.
Rafael Espindola
rafael.espindola at gmail.com
Mon Jul 8 09:16:51 PDT 2013
Author: rafael
Date: Mon Jul 8 11:16:51 2013
New Revision: 185832
URL: http://llvm.org/viewvc/llvm-project?rev=185832&view=rev
Log:
Create files with the correct permission instead of changing it afterwards.
No intended functionality change.
Modified:
llvm/trunk/tools/llvm-ar/llvm-ar.cpp
Modified: llvm/trunk/tools/llvm-ar/llvm-ar.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-ar/llvm-ar.cpp?rev=185832&r1=185831&r2=185832&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-ar/llvm-ar.cpp (original)
+++ llvm/trunk/tools/llvm-ar/llvm-ar.cpp Mon Jul 8 11:16:51 2013
@@ -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());
}
More information about the llvm-commits
mailing list