[Box Backup-commit] COMMIT r2635 - in box/trunk: bin/bbackupquery lib/backupclient
subversion at boxbackup.org
subversion at boxbackup.org
Wed Feb 24 20:12:01 GMT 2010
Author: chris
Date: 2010-02-24 20:12:00 +0000 (Wed, 24 Feb 2010)
New Revision: 2635
Modified:
box/trunk/bin/bbackupquery/BackupQueries.cpp
box/trunk/lib/backupclient/BackupClientFileAttributes.cpp
box/trunk/lib/backupclient/BackupClientFileAttributes.h
Log:
Add method to get updated modification time of
BackupClientFileAttributes.
Add listing of attribute modification time to bbackupquery "list -t"
command.
Modified: box/trunk/bin/bbackupquery/BackupQueries.cpp
===================================================================
--- box/trunk/bin/bbackupquery/BackupQueries.cpp 2010-02-24 19:39:39 UTC (rev 2634)
+++ box/trunk/bin/bbackupquery/BackupQueries.cpp 2010-02-24 20:12:00 UTC (rev 2635)
@@ -435,7 +435,23 @@
List(rootDir, listRoot, opts, true /* first level to list */);
}
+static std::string GetTimeString(BackupStoreDirectory::Entry& en,
+ bool useLocalTime)
+{
+ std::ostringstream out;
+ out << BoxTimeToISO8601String(en.GetModificationTime(), useLocalTime);
+ if(en.HasAttributes())
+ {
+ const StreamableMemBlock &storeAttr(en.GetAttributes());
+ BackupClientFileAttributes attr(storeAttr);
+ out << "~" << BoxTimeToISO8601String(attr.GetModificationTime(),
+ useLocalTime);
+ }
+
+ return out.str();
+}
+
// --------------------------------------------------------------------------
//
// Function
@@ -534,17 +550,13 @@
if(opts[LIST_OPTION_TIMES_UTC])
{
// Show UTC times...
- std::string time = BoxTimeToISO8601String(
- en->GetModificationTime(), false);
- printf("%s ", time.c_str());
+ printf("%s ", GetTimeString(*en, false).c_str());
}
if(opts[LIST_OPTION_TIMES_LOCAL])
{
// Show local times...
- std::string time = BoxTimeToISO8601String(
- en->GetModificationTime(), true);
- printf("%s ", time.c_str());
+ printf("%s ", GetTimeString(*en, true).c_str());
}
if(opts[LIST_OPTION_DISPLAY_HASH])
Modified: box/trunk/lib/backupclient/BackupClientFileAttributes.cpp
===================================================================
--- box/trunk/lib/backupclient/BackupClientFileAttributes.cpp 2010-02-24 19:39:39 UTC (rev 2634)
+++ box/trunk/lib/backupclient/BackupClientFileAttributes.cpp 2010-02-24 20:12:00 UTC (rev 2635)
@@ -647,7 +647,53 @@
#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);
+}
+
// --------------------------------------------------------------------------
//
// Function
Modified: box/trunk/lib/backupclient/BackupClientFileAttributes.h
===================================================================
--- box/trunk/lib/backupclient/BackupClientFileAttributes.h 2010-02-24 19:39:39 UTC (rev 2634)
+++ box/trunk/lib/backupclient/BackupClientFileAttributes.h 2010-02-24 20:12:00 UTC (rev 2635)
@@ -47,7 +47,8 @@
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);
More information about the Boxbackup-commit
mailing list