CernVM-FS  2.12.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sink_path.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_NETWORK_SINK_PATH_H_
6 #define CVMFS_NETWORK_SINK_PATH_H_
7 
8 #include <cerrno>
9 #include <cstdio>
10 #include <string>
11 
12 #include "sink.h"
13 #include "sink_file.h"
14 #include "util/pointer.h"
15 #include "util/posix.h"
16 
17 namespace cvmfs {
18 
30 class PathSink : public Sink {
31  public:
32  explicit PathSink(const std::string &destination_path);
33 
34  virtual ~PathSink() { } // UniquePtr<FileSink> sink_ takes care of everything
35 
42  virtual int64_t Write(const void *buf, uint64_t sz) {
43  return sink_->Write(buf, sz);
44  }
45 
52  virtual int Reset() {
53  return sink_->Reset();
54  }
55 
56  virtual int Purge();
57 
61  virtual bool IsValid() {
62  return sink_->IsValid();
63  }
64 
70  virtual int Flush() {
71  return sink_->Flush();
72  }
73 
90  virtual bool Reserve(size_t size) {
91  return sink_->Reserve(size);
92  }
93 
100  virtual bool RequiresReserve() {
101  return sink_->RequiresReserve();
102  }
103 
107  virtual std::string Describe();
108 
109  const std::string path() { return path_; }
110 
111  private:
112  FILE *file_; // owned by sink_
114  const std::string path_;
115 };
116 
117 } // namespace cvmfs
118 
119 #endif // CVMFS_NETWORK_SINK_PATH_H_
virtual bool RequiresReserve()
Definition: sink_path.h:100
virtual int Flush()
Definition: sink_path.h:70
virtual int64_t Write(const void *buf, uint64_t sz)
Definition: sink_path.h:42
UniquePtr< FileSink > sink_
Definition: sink_path.h:113
virtual bool IsValid()
Definition: sink_path.h:61
virtual bool Reserve(size_t size)
Definition: sink_path.h:90
const std::string path()
Definition: sink_path.h:109
virtual int Reset()
Definition: sink_path.h:52
virtual std::string Describe()
Definition: sink_path.cc:46
virtual int Purge()
Definition: sink_path.cc:30
virtual ~PathSink()
Definition: sink_path.h:34
static void size_t size
Definition: smalloc.h:54
const std::string path_
Definition: sink_path.h:114
PathSink(const std::string &destination_path)
Definition: sink_path.cc:15