CernVM-FS  2.13.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
sink_path.cc
Go to the documentation of this file.
1 
5 #include "sink_path.h"
6 
7 #include <cerrno>
8 #include <cstdio>
9 #include <string>
10 
11 #include "util/posix.h"
12 
13 
14 namespace cvmfs {
15 
16 PathSink::PathSink(const std::string &destination_path)
17  : Sink(true), path_(destination_path) {
18  file_ = fopen(destination_path.c_str(), "w");
19  sink_ = new FileSink(file_, true);
20 }
21 
32  const int ret = sink_->Purge();
33  const int ret2 = unlink(path_.c_str());
34 
35  if (ret != 0) {
36  return ret;
37  }
38  if (ret2 != 0) {
39  return ret2;
40  }
41  return 0;
42 }
43 
47 std::string PathSink::Describe() {
48  std::string result = "Path sink for ";
49  result += "path " + path_ + " and ";
50  result += IsValid() ? " valid file pointer" : " invalid file pointer";
51  return result;
52 }
53 
54 } // namespace cvmfs
UniquePtr< FileSink > sink_
Definition: sink_path.h:102
virtual bool IsValid()
Definition: sink_path.h:58
virtual std::string Describe()
Definition: sink_path.cc:47
virtual int Purge()
Definition: sink_path.cc:31
const std::string path_
Definition: sink_path.h:103
PathSink(const std::string &destination_path)
Definition: sink_path.cc:16