[llvm] r185937 - Add missing getters. They will be used in llvm-ar.
Rafael Espindola
rafael.espindola at gmail.com
Tue Jul 9 05:49:24 PDT 2013
Author: rafael
Date: Tue Jul 9 07:49:24 2013
New Revision: 185937
URL: http://llvm.org/viewvc/llvm-project?rev=185937&view=rev
Log:
Add missing getters. They will be used in llvm-ar.
Modified:
llvm/trunk/include/llvm/Object/Archive.h
llvm/trunk/lib/Object/Archive.cpp
Modified: llvm/trunk/include/llvm/Object/Archive.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/Archive.h?rev=185937&r1=185936&r2=185937&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/Archive.h (original)
+++ llvm/trunk/include/llvm/Object/Archive.h Tue Jul 9 07:49:24 2013
@@ -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; }
Modified: llvm/trunk/lib/Object/Archive.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Archive.cpp?rev=185937&r1=185936&r2=185937&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Archive.cpp (original)
+++ llvm/trunk/lib/Object/Archive.cpp Tue Jul 9 07:49:24 2013
@@ -61,6 +61,38 @@ uint32_t ArchiveMemberHeader::getSize()
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);
}
More information about the llvm-commits
mailing list