From aaf98b770db720d8a866e135b7cf39ab144032b1 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 24 Feb 2010 20:12:00 +0000 Subject: Add method to get updated modification time of BackupClientFileAttributes. Add listing of attribute modification time to bbackupquery "list -t" command. --- lib/backupclient/BackupClientFileAttributes.cpp | 46 +++++++++++++++++++++++++ lib/backupclient/BackupClientFileAttributes.h | 3 +- 2 files changed, 48 insertions(+), 1 deletion(-) (limited to 'lib/backupclient') diff --git a/lib/backupclient/BackupClientFileAttributes.cpp b/lib/backupclient/BackupClientFileAttributes.cpp index 5a47fe74..32c30395 100644 --- a/lib/backupclient/BackupClientFileAttributes.cpp +++ b/lib/backupclient/BackupClientFileAttributes.cpp @@ -647,6 +647,52 @@ void BackupClientFileAttributes::FillExtendedAttr(StreamableMemBlock &outputBloc #endif } +// -------------------------------------------------------------------------- +// +// Function +// Name: BackupClientFileAttributes::GetModificationTime() +// Purpose: Returns the modification time embedded in the +// attributes. +// Created: 2010/02/24 +// +// -------------------------------------------------------------------------- +box_time_t BackupClientFileAttributes::GetModificationTime() const +{ + // Got something loaded + if(GetSize() <= 0) + { + THROW_EXCEPTION(BackupStoreException, AttributesNotLoaded); + } + + // Make sure there are clear attributes to use + EnsureClearAvailable(); + ASSERT(mpClearAttributes != 0); + + // Check if the decrypted attributes are small enough, and the type of attributes stored + if(mpClearAttributes->GetSize() < (int)sizeof(int32_t)) + { + THROW_EXCEPTION(BackupStoreException, AttributesNotUnderstood); + } + int32_t *type = (int32_t*)mpClearAttributes->GetBuffer(); + ASSERT(type != 0); + if(ntohl(*type) != ATTRIBUTETYPE_GENERIC_UNIX) + { + // Don't know what to do with these + THROW_EXCEPTION(BackupStoreException, AttributesNotUnderstood); + } + + // Check there is enough space for an attributes block + if(mpClearAttributes->GetSize() < (int)sizeof(attr_StreamFormat)) + { + // Too small + THROW_EXCEPTION(BackupStoreException, AttributesNotLoaded); + } + + // Get pointer to structure + attr_StreamFormat *pattr = (attr_StreamFormat*)mpClearAttributes->GetBuffer(); + + return box_ntoh64(pattr->ModificationTime); +} // -------------------------------------------------------------------------- // diff --git a/lib/backupclient/BackupClientFileAttributes.h b/lib/backupclient/BackupClientFileAttributes.h index b32c14dd..bd45dd18 100644 --- a/lib/backupclient/BackupClientFileAttributes.h +++ b/lib/backupclient/BackupClientFileAttributes.h @@ -47,7 +47,8 @@ public: InodeRefType *pInodeNumber = 0, bool *pHasMultipleLinks = 0); void WriteAttributes(const char *Filename, bool MakeUserWritable = false) const; - + box_time_t GetModificationTime() const; + bool IsSymLink() const; static void SetBlowfishKey(const void *pKey, int KeyLength); -- cgit v1.2.3