mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-25 04:39:44 +00:00
Use open+fstat instead of stat+open.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186381 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
289e241d77
commit
bd6cb260b9
@ -555,13 +555,23 @@ static void performWriteOperation(ArchiveOperation Operation,
|
|||||||
printWithSpacePadding(Out, Name, 16);
|
printWithSpacePadding(Out, Name, 16);
|
||||||
|
|
||||||
if (I->isNewMember()) {
|
if (I->isNewMember()) {
|
||||||
// FIXME: we do a stat + open. We should do a open + fstat.
|
|
||||||
const char *FileName = I->getNew();
|
const char *FileName = I->getNew();
|
||||||
|
|
||||||
|
int OpenFlags = O_RDONLY;
|
||||||
|
#ifdef O_BINARY
|
||||||
|
OpenFlags |= O_BINARY;
|
||||||
|
#endif
|
||||||
|
int FD = ::open(FileName, OpenFlags);
|
||||||
|
if (FD == -1)
|
||||||
|
return failIfError(error_code(errno, posix_category()), FileName);
|
||||||
|
|
||||||
sys::fs::file_status Status;
|
sys::fs::file_status Status;
|
||||||
failIfError(sys::fs::status(FileName, Status), FileName);
|
failIfError(sys::fs::status(FD, Status), FileName);
|
||||||
|
|
||||||
OwningPtr<MemoryBuffer> File;
|
OwningPtr<MemoryBuffer> File;
|
||||||
failIfError(MemoryBuffer::getFile(FileName, File), FileName);
|
failIfError(
|
||||||
|
MemoryBuffer::getOpenFile(FD, FileName, File, Status.getSize()),
|
||||||
|
FileName);
|
||||||
|
|
||||||
uint64_t secondsSinceEpoch =
|
uint64_t secondsSinceEpoch =
|
||||||
Status.getLastModificationTime().toEpochTime();
|
Status.getLastModificationTime().toEpochTime();
|
||||||
|
Loading…
Reference in New Issue
Block a user