CernVM-FS  2.13.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() { return sink_->Reset(); }
52 
53  virtual int Purge();
54 
58  virtual bool IsValid() { return sink_->IsValid(); }
59 
65  virtual int Flush() { return sink_->Flush(); }
66 
83  virtual bool Reserve(size_t size) { return sink_->Reserve(size); }
84 
91  virtual bool RequiresReserve() { return sink_->RequiresReserve(); }
92 
96  virtual std::string Describe();
97 
98  const std::string path() { return path_; }
99 
100  private:
101  FILE *file_; // owned by sink_
103  const std::string path_;
104 };
105 
106 } // namespace cvmfs
107 
108 #endif // CVMFS_NETWORK_SINK_PATH_H_
virtual bool RequiresReserve()
Definition: sink_path.h:91
virtual int Flush()
Definition: sink_path.h:65
virtual int64_t Write(const void *buf, uint64_t sz)
Definition: sink_path.h:41
UniquePtr< FileSink > sink_
Definition: sink_path.h:102
virtual bool IsValid()
Definition: sink_path.h:58
virtual bool Reserve(size_t size)
Definition: sink_path.h:83
const std::string path()
Definition: sink_path.h:98
virtual int Reset()
Definition: sink_path.h:51
virtual std::string Describe()
Definition: sink_path.cc:47
virtual int Purge()
Definition: sink_path.cc:31
virtual ~PathSink()
Definition: sink_path.h:33
static void size_t size
Definition: smalloc.h:54
const std::string path_
Definition: sink_path.h:103
PathSink(const std::string &destination_path)
Definition: sink_path.cc:16