CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sync_union.h
Go to the documentation of this file.
1 
30 #ifndef CVMFS_SYNC_UNION_H_
31 #define CVMFS_SYNC_UNION_H_
32 
33 #include <set>
34 #include <string>
35 
36 #include "sync_item.h"
37 #include "util/shared_ptr.h"
38 
39 namespace publish {
40 
41 class AbstractSyncMediator;
42 class SyncMediator;
43 
49 };
50 
55 class SyncUnion {
56  public:
65  SyncUnion(AbstractSyncMediator *mediator, const std::string &rdonly_path,
66  const std::string &union_path, const std::string &scratch_path);
67  virtual ~SyncUnion() {}
68 
74  virtual bool Initialize();
75 
79  virtual void Traverse() = 0;
80 
81  virtual void PostUpload() { }
82 
92  SharedPtr<SyncItem> CreateSyncItem(const std::string &relative_parent_path,
93  const std::string &filename,
94  const SyncItemType entry_type) const;
95 
96  inline std::string rdonly_path() const { return rdonly_path_; }
97  inline std::string union_path() const { return union_path_; }
98  inline std::string scratch_path() const { return scratch_path_; }
99 
106  virtual std::string UnwindWhiteoutFilename(
107  SharedPtr<SyncItem> entry) const = 0;
108 
118  virtual bool IsOpaqueDirectory(SharedPtr<SyncItem> directory) const = 0;
119 
126  virtual bool IsWhiteoutEntry(SharedPtr<SyncItem> entry) const = 0;
127 
136  virtual bool IgnoreFilePredicate(const std::string &parent_dir,
137  const std::string &filename);
138 
139  bool IsInitialized() const { return initialized_; }
140  virtual bool SupportsHardlinks() const { return false; }
141 
142  protected:
143  std::string rdonly_path_;
144  std::string scratch_path_;
145  std::string union_path_;
146 
148 
158  virtual void PreprocessSyncItem(SharedPtr<SyncItem> entry) const;
159 
165  virtual void ProcessRegularFile(const std::string &parent_dir,
166  const std::string &filename);
167 
175  virtual bool ProcessDirectory(const std::string &parent_dir,
176  const std::string &dir_name);
177  virtual bool ProcessDirectory(SharedPtr<SyncItem> entry);
179 
185  virtual void ProcessSymlink(const std::string &parent_dir,
186  const std::string &link_name);
187 
192  virtual void EnterDirectory(const std::string &parent_dir,
193  const std::string &dir_name);
194 
199  virtual void LeaveDirectory(const std::string &parent_dir,
200  const std::string &dir_name);
201 
207  void ProcessCharacterDevice(const std::string &parent_dir,
208  const std::string &filename);
209 
215  void ProcessBlockDevice(const std::string &parent_dir,
216  const std::string &filename);
217 
223  void ProcessFifo(const std::string &parent_dir, const std::string &filename);
224 
230  void ProcessSocket(const std::string &parent_dir,
231  const std::string &filename);
232 
237  void ProcessFile(SharedPtr<SyncItem> entry);
238 
239  private:
241 }; // class SyncUnion
242 
243 } // namespace publish
244 
245 #endif // CVMFS_SYNC_UNION_H_
virtual void LeaveDirectory(const std::string &parent_dir, const std::string &dir_name)
Definition: sync_union.cc:141
virtual bool ProcessUnmaterializedDirectory(SharedPtr< SyncItem > entry)
Definition: sync_union.cc:92
virtual bool SupportsHardlinks() const
Definition: sync_union.h:140
std::string scratch_path_
Definition: sync_union.h:144
virtual bool Initialize()
Definition: sync_union.cc:24
std::string rdonly_path_
Definition: sync_union.h:143
virtual void PreprocessSyncItem(SharedPtr< SyncItem > entry) const
Definition: sync_union.cc:47
std::string union_path_
Definition: sync_union.h:145
virtual bool IsOpaqueDirectory(SharedPtr< SyncItem > directory) const =0
std::string scratch_path() const
Definition: sync_union.h:98
virtual void PostUpload()
Definition: sync_union.h:81
virtual std::string UnwindWhiteoutFilename(SharedPtr< SyncItem > entry) const =0
SharedPtr< SyncItem > CreateSyncItem(const std::string &relative_parent_path, const std::string &filename, const SyncItemType entry_type) const
Definition: sync_union.cc:30
virtual void ProcessSymlink(const std::string &parent_dir, const std::string &link_name)
Definition: sync_union.cc:107
std::string union_path() const
Definition: sync_union.h:97
AbstractSyncMediator * mediator_
Definition: sync_union.h:147
bool IsInitialized() const
Definition: sync_union.h:139
void ProcessBlockDevice(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:157
virtual bool IgnoreFilePredicate(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:57
void ProcessSocket(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:175
virtual void ProcessRegularFile(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:99
SyncUnion(AbstractSyncMediator *mediator, const std::string &rdonly_path, const std::string &union_path, const std::string &scratch_path)
Definition: sync_union.cc:14
virtual ~SyncUnion()
Definition: sync_union.h:67
void ProcessFile(SharedPtr< SyncItem > entry)
Definition: sync_union.cc:116
virtual void Traverse()=0
virtual bool IsWhiteoutEntry(SharedPtr< SyncItem > entry) const =0
SyncItemType
Definition: sync_item.h:29
virtual bool ProcessDirectory(const std::string &parent_dir, const std::string &dir_name)
virtual void EnterDirectory(const std::string &parent_dir, const std::string &dir_name)
Definition: sync_union.cc:135
void ProcessFifo(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:167
std::string rdonly_path() const
Definition: sync_union.h:96
void ProcessCharacterDevice(const std::string &parent_dir, const std::string &filename)
Definition: sync_union.cc:147