summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/bbackupquery/BackupQueries.cpp24
-rw-r--r--lib/backupclient/BackupClientFileAttributes.cpp46
-rw-r--r--lib/backupclient/BackupClientFileAttributes.h3
3 files changed, 66 insertions, 7 deletions
diff --git a/bin/bbackupquery/BackupQueries.cpp b/bin/bbackupquery/BackupQueries.cpp
index 15257fc3..f0433ae2 100644
--- a/bin/bbackupquery/BackupQueries.cpp
+++ b/bin/bbackupquery/BackupQueries.cpp
@@ -435,6 +435,22 @@ void BackupQueries::CommandList(const std::vector<std::string> &args, const bool
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();
+}
// --------------------------------------------------------------------------
//
@@ -534,17 +550,13 @@ void BackupQueries::List(int64_t DirID, const std::string &rListRoot, const bool
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])
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);