diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-09 12:49:24 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-07-09 12:49:24 +0000 |
commit | 9941bdd1fec00aa7a72117d2c2e21724c275e89a (patch) | |
tree | 63dabea0ca2fb3781eb4ed796f93d213d6e39045 | |
parent | 2012593f180d29081e6c609f667e1f63b729209a (diff) | |
download | external_llvm-9941bdd1fec00aa7a72117d2c2e21724c275e89a.zip external_llvm-9941bdd1fec00aa7a72117d2c2e21724c275e89a.tar.gz external_llvm-9941bdd1fec00aa7a72117d2c2e21724c275e89a.tar.bz2 |
Add missing getters. They will be used in llvm-ar.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@185937 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/Object/Archive.h | 14 | ||||
-rw-r--r-- | lib/Object/Archive.cpp | 32 |
2 files changed, 46 insertions, 0 deletions
diff --git a/include/llvm/Object/Archive.h b/include/llvm/Object/Archive.h index 0559557..0be0c15 100644 --- a/include/llvm/Object/Archive.h +++ b/include/llvm/Object/Archive.h @@ -17,6 +17,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Object/Binary.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/MemoryBuffer.h" namespace llvm { @@ -35,6 +36,11 @@ struct ArchiveMemberHeader { /// Members are not larger than 4GB. uint32_t getSize() const; + + sys::fs::perms getAccessMode() const; + sys::TimeValue getLastModified() const; + unsigned getUID() const; + unsigned getGID() const; }; class Archive : public Binary { @@ -67,6 +73,14 @@ public: error_code getName(StringRef &Result) const; StringRef getRawName() const { return getHeader()->getName(); } + sys::TimeValue getLastModified() const { + return getHeader()->getLastModified(); + } + unsigned getUID() const { return getHeader()->getUID(); } + unsigned getGID() const { return getHeader()->getGID(); } + sys::fs::perms getAccessMode() const { + return getHeader()->getAccessMode(); + } /// \return the size of the archive member without the header or padding. uint64_t getSize() const { return Data.size() - StartOfFile; } diff --git a/lib/Object/Archive.cpp b/lib/Object/Archive.cpp index 5257894..292d50a 100644 --- a/lib/Object/Archive.cpp +++ b/lib/Object/Archive.cpp @@ -61,6 +61,38 @@ uint32_t ArchiveMemberHeader::getSize() const { return Ret; } +sys::fs::perms ArchiveMemberHeader::getAccessMode() const { + unsigned Ret; + if (StringRef(AccessMode, sizeof(AccessMode)).rtrim(" ").getAsInteger(8, Ret)) + llvm_unreachable("Access mode is not an octal number."); + return static_cast<sys::fs::perms>(Ret); +} + +sys::TimeValue ArchiveMemberHeader::getLastModified() const { + unsigned Seconds; + if (StringRef(LastModified, sizeof(LastModified)).rtrim(" ") + .getAsInteger(10, Seconds)) + llvm_unreachable("Last modified time not a decimal number."); + + sys::TimeValue Ret; + Ret.fromEpochTime(Seconds); + return Ret; +} + +unsigned ArchiveMemberHeader::getUID() const { + unsigned Ret; + if (StringRef(UID, sizeof(UID)).rtrim(" ").getAsInteger(10, Ret)) + llvm_unreachable("UID time not a decimal number."); + return Ret; +} + +unsigned ArchiveMemberHeader::getGID() const { + unsigned Ret; + if (StringRef(GID, sizeof(GID)).rtrim(" ").getAsInteger(10, Ret)) + llvm_unreachable("GID time not a decimal number."); + return Ret; +} + static const ArchiveMemberHeader *toHeader(const char *base) { return reinterpret_cast<const ArchiveMemberHeader *>(base); } |