source: box/trunk/lib/backupstore/BackupClientFileAttributes.h @ 2945

Last change on this file since 2945 was 2945, checked in by chris, 4 years ago

Major refactoring to make lib/backupclient depend on lib/backupstore rather
than the other way around. This is needed to allow clients to have all the
code that they'd need to implement local backups (using the Local protocol)
in subsequent commits.

  • Property svn:eol-style set to native
File size: 2.9 KB
Line 
1// --------------------------------------------------------------------------
2//
3// File
4//              Name:    BackupClientFileAttributes.h
5//              Purpose: Storage of file attributes
6//              Created: 2003/10/07
7//
8// --------------------------------------------------------------------------
9
10#ifndef BACKUPCLIENTFILEATTRIBUTES__H
11#define BACKUPCLIENTFILEATTRIBUTES__H
12
13#include <string>
14
15#include "StreamableMemBlock.h"
16#include "BoxTime.h"
17
18EMU_STRUCT_STAT; // declaration
19
20// --------------------------------------------------------------------------
21//
22// Class
23//              Name:    BackupClientFileAttributes
24//              Purpose: Storage, streaming and application of file attributes
25//              Created: 2003/10/07
26//
27// --------------------------------------------------------------------------
28class BackupClientFileAttributes : public StreamableMemBlock
29{
30public:
31        BackupClientFileAttributes();
32        BackupClientFileAttributes(const BackupClientFileAttributes &rToCopy);
33        BackupClientFileAttributes(const StreamableMemBlock &rToCopy);
34        ~BackupClientFileAttributes();
35        BackupClientFileAttributes &operator=(const BackupClientFileAttributes &rAttr);
36        BackupClientFileAttributes &operator=(const StreamableMemBlock &rAttr);
37        bool operator==(const BackupClientFileAttributes &rAttr) const;
38//      bool operator==(const StreamableMemBlock &rAttr) const; // too dangerous?
39
40        bool Compare(const BackupClientFileAttributes &rAttr, bool IgnoreAttrModTime = false, bool IgnoreModTime = false) const;
41       
42        // Prevent access to base class members accidently
43        void Set();
44
45        void ReadAttributes(const char *Filename, bool ZeroModificationTimes = false,
46                box_time_t *pModTime = 0, box_time_t *pAttrModTime = 0, int64_t *pFileSize = 0,
47                InodeRefType *pInodeNumber = 0, bool *pHasMultipleLinks = 0);
48        void WriteAttributes(const char *Filename, 
49                bool MakeUserWritable = false) const;
50        void GetModificationTimes(box_time_t *pModificationTime,
51                box_time_t *pAttrModificationTime) const;
52       
53        bool IsSymLink() const;
54
55        static void SetBlowfishKey(const void *pKey, int KeyLength);
56        static void SetAttributeHashSecret(const void *pSecret, int SecretLength);
57       
58        static uint64_t GenerateAttributeHash(EMU_STRUCT_STAT &st, const std::string &filename, const std::string &leafname);
59        static void FillExtendedAttr(StreamableMemBlock &outputBlock, const char *Filename);
60
61private:
62        static void FillAttributes(StreamableMemBlock &outputBlock,
63                const char *Filename, EMU_STRUCT_STAT &st,
64                bool ZeroModificationTimes);
65        static void FillAttributesLink(StreamableMemBlock &outputBlock, const char *Filename, struct stat &st);
66        void WriteExtendedAttr(const char *Filename, int xattrOffset) const;
67
68        void RemoveClear() const;
69        void EnsureClearAvailable() const;
70        static StreamableMemBlock *MakeClear(const StreamableMemBlock &rEncrypted);
71        void EncryptAttr(const StreamableMemBlock &rToEncrypt);
72
73private:
74        mutable StreamableMemBlock *mpClearAttributes;
75};
76
77#endif // BACKUPCLIENTFILEATTRIBUTES__H
78
Note: See TracBrowser for help on using the repository browser.