GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/network/sink_path.cc
Date: 2025-06-29 02:35:41
Exec Total Coverage
Lines: 11 18 61.1%
Branches: 7 28 25.0%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #include "sink_path.h"
6
7 #include <cerrno>
8 #include <cstdio>
9 #include <string>
10 #include <unistd.h>
11
12 #include "util/posix.h"
13
14
15 namespace cvmfs {
16
17 40 PathSink::PathSink(const std::string &destination_path)
18
2/4
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 40 times.
✗ Branch 6 not taken.
40 : Sink(true), path_(destination_path) {
19
1/2
✓ Branch 2 taken 40 times.
✗ Branch 3 not taken.
40 file_ = fopen(destination_path.c_str(), "w");
20
2/4
✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 40 times.
✗ Branch 6 not taken.
40 sink_ = new FileSink(file_, true);
21 40 }
22
23 /**
24 * Purges all resources leaving the sink in an invalid state.
25 * More aggressive version of Reset().
26 * For some sinks and depending on owner status it might do
27 * the same as Reset().
28 *
29 * @returns Success = 0
30 * Failure = -errno
31 */
32 10 int PathSink::Purge() {
33 10 const int ret = sink_->Purge();
34 10 const int ret2 = unlink(path_.c_str());
35
36
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (ret != 0) {
37 return ret;
38 }
39
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if (ret2 != 0) {
40 return ret2;
41 }
42 10 return 0;
43 }
44
45 /**
46 * Return a string representation describing the type of sink and its status
47 */
48 std::string PathSink::Describe() {
49 std::string result = "Path sink for ";
50 result += "path " + path_ + " and ";
51 result += IsValid() ? " valid file pointer" : " invalid file pointer";
52 return result;
53 }
54
55 } // namespace cvmfs
56