From 24f341ac16373577c9737042306f930f484e1802 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 22 Jan 2012 16:35:37 +0000 Subject: Allow constructing a BackupClientFileAttributes from a struct EMU_STAT. --- lib/backupstore/BackupClientFileAttributes.cpp | 37 +++++++++++++++++++++++--- lib/backupstore/BackupClientFileAttributes.h | 3 ++- 2 files changed, 35 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/backupstore/BackupClientFileAttributes.cpp b/lib/backupstore/BackupClientFileAttributes.cpp index bc39bd8b..372f9e32 100644 --- a/lib/backupstore/BackupClientFileAttributes.cpp +++ b/lib/backupstore/BackupClientFileAttributes.cpp @@ -120,6 +120,30 @@ BackupClientFileAttributes::BackupClientFileAttributes() ASSERT(sizeof(u_int64_t) == sizeof(box_time_t)); } +// -------------------------------------------------------------------------- +// +// Function +// Name: BackupClientFileAttributes::BackupClientFileAttributes() +// Purpose: Artifical constructor +// Created: 2011/12/06 +// +// -------------------------------------------------------------------------- +BackupClientFileAttributes::BackupClientFileAttributes(const EMU_STRUCT_STAT &st) +: mpClearAttributes(0) +{ + ASSERT(sizeof(u_int64_t) == sizeof(box_time_t)); + StreamableMemBlock *pnewAttr = new StreamableMemBlock; + FillAttributes(*pnewAttr, (const char *)NULL, st, true); + + // Attributes ready. Encrypt into this block + EncryptAttr(*pnewAttr); + + // Store the new attributes + RemoveClear(); + mpClearAttributes = pnewAttr; + pnewAttr = 0; +} + // -------------------------------------------------------------------------- // // Function @@ -436,12 +460,15 @@ void BackupClientFileAttributes::ReadAttributes(const char *Filename, // -------------------------------------------------------------------------- // // Function -// Name: BackupClientFileAttributes::ReadAttributesLink() +// Name: BackupClientFileAttributes::FillAttributes() // Purpose: Private function, handles standard attributes for all objects // Created: 2003/10/07 // // -------------------------------------------------------------------------- -void BackupClientFileAttributes::FillAttributes(StreamableMemBlock &outputBlock, const char *Filename, EMU_STRUCT_STAT &st, bool ZeroModificationTimes) +void BackupClientFileAttributes::FillAttributes( + StreamableMemBlock &outputBlock, const char *Filename, + const EMU_STRUCT_STAT &st, bool ZeroModificationTimes +) { outputBlock.ResizeBlock(sizeof(attr_StreamFormat)); attr_StreamFormat *pattr = (attr_StreamFormat*)outputBlock.GetBuffer(); @@ -475,7 +502,9 @@ void BackupClientFileAttributes::FillAttributes(StreamableMemBlock &outputBlock, // -------------------------------------------------------------------------- // // Function -// Name: BackupClientFileAttributes::ReadAttributesLink() +// Name: BackupClientFileAttributes::FillAttributesLink( +// StreamableMemBlock &outputBlock, +// const char *Filename, struct stat &st) // Purpose: Private function, handles the case where a symbolic link is needed // Created: 2003/10/07 // @@ -507,7 +536,7 @@ void BackupClientFileAttributes::FillAttributesLink(StreamableMemBlock &outputBl // -------------------------------------------------------------------------- // // Function -// Name: BackupClientFileAttributes::ReadExtendedAttr(const char *, unsigned char**) +// Name: BackupClientFileAttributes::FillExtendedAttr(const char *, unsigned char**) // Purpose: Private function, read the extended attributes of the file into the block // Created: 2005/06/12 // diff --git a/lib/backupstore/BackupClientFileAttributes.h b/lib/backupstore/BackupClientFileAttributes.h index f9a0d883..8ae7ffc2 100644 --- a/lib/backupstore/BackupClientFileAttributes.h +++ b/lib/backupstore/BackupClientFileAttributes.h @@ -29,6 +29,7 @@ class BackupClientFileAttributes : public StreamableMemBlock { public: BackupClientFileAttributes(); + BackupClientFileAttributes(const EMU_STRUCT_STAT &st); BackupClientFileAttributes(const BackupClientFileAttributes &rToCopy); BackupClientFileAttributes(const StreamableMemBlock &rToCopy); ~BackupClientFileAttributes(); @@ -60,7 +61,7 @@ public: private: static void FillAttributes(StreamableMemBlock &outputBlock, - const char *Filename, EMU_STRUCT_STAT &st, + const char *Filename, const EMU_STRUCT_STAT &st, bool ZeroModificationTimes); static void FillAttributesLink(StreamableMemBlock &outputBlock, const char *Filename, struct stat &st); void WriteExtendedAttr(const char *Filename, int xattrOffset) const; -- cgit v1.2.3