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 
16 namespace cvmfs {
17 
29 class PathSink : public Sink {
30  public:
31  explicit PathSink(const std::string &destination_path);
32 
33  virtual ~PathSink() { } // UniquePtr<FileSink> sink_ takes care of everything
34 
41  virtual int64_t Write(const void *buf, uint64_t sz) {
42  return sink_->Write(buf, sz);
43  }
44 
51  virtual int Reset() {
52  return sink_->Reset();
53  }
54 
55  virtual int Purge();
56 
60  virtual bool IsValid() {
61  return sink_->IsValid();
62  }
63 
69  virtual int Flush() {
70  return sink_->Flush();
71  }
72 
89  virtual bool Reserve(size_t size) {
90  return sink_->Reserve(size);
91  }
92 
99  virtual bool RequiresReserve() {
100  return sink_->RequiresReserve();
101  }
102 
106  virtual std::string Describe();
107 
108  const std::string path() { return path_; }
109 
110  private:
111  FILE *file_; // owned by sink_
113  const std::string path_;
114 };
115 
116 } // namespace cvmfs
117 
118 #endif // CVMFS_NETWORK_SINK_PATH_H_
virtual bool RequiresReserve()
Definition: sink_path.h:99
virtual int Flush()
Definition: sink_path.h:69
virtual int64_t Write(const void *buf, uint64_t sz)
Definition: sink_path.h:41
UniquePtr< FileSink > sink_
Definition: sink_path.h:112
virtual bool IsValid()
Definition: sink_path.h:60
virtual bool Reserve(size_t size)
Definition: sink_path.h:89
const std::string path()
Definition: sink_path.h:108
virtual int Reset()
Definition: sink_path.h:51
virtual std::string Describe()
Definition: sink_path.cc:46
virtual int Purge()
Definition: sink_path.cc:30
virtual ~PathSink()
Definition: sink_path.h:33
static void size_t size
Definition: smalloc.h:54
const std::string path_
Definition: sink_path.h:113
PathSink(const std::string &destination_path)
Definition: sink_path.cc:15