CernVM-FS  2.12.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 <cerrno>
6 #include <cstdio>
7 #include <string>
8 
9 #include "sink_path.h"
10 #include "util/posix.h"
11 
12 
13 namespace cvmfs {
14 
15 PathSink::PathSink(const std::string &destination_path) : Sink(true),
16  path_(destination_path) {
17  file_ = fopen(destination_path.c_str(), "w");
18  sink_ = new FileSink(file_, true);
19 }
20 
31  int ret = sink_->Purge();
32  int ret2 = unlink(path_.c_str());
33 
34  if (ret != 0) {
35  return ret;
36  }
37  if (ret2 != 0) {
38  return ret2;
39  }
40  return 0;
41 }
42 
46 std::string PathSink::Describe() {
47  std::string result = "Path sink for ";
48  result += "path " + path_ + " and ";
49  result += IsValid() ? " valid file pointer" : " invalid file pointer";
50  return result;
51 }
52 
53 } // namespace cvmfs
UniquePtr< FileSink > sink_
Definition: sink_path.h:113
virtual bool IsValid()
Definition: sink_path.h:61
virtual std::string Describe()
Definition: sink_path.cc:46
virtual int Purge()
Definition: sink_path.cc:30
const std::string path_
Definition: sink_path.h:114
PathSink(const std::string &destination_path)
Definition: sink_path.cc:15