| Directory: | cvmfs/ |
|---|---|
| File: | cvmfs/util/raii_temp_dir.cc |
| Date: | 2025-11-02 02:35:35 |
| Exec | Total | Coverage | |
|---|---|---|---|
| Lines: | 7 | 9 | 77.8% |
| Branches: | 3 | 8 | 37.5% |
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /** | ||
| 2 | * This file is part of the CernVM File System. | ||
| 3 | */ | ||
| 4 | |||
| 5 | #include "raii_temp_dir.h" | ||
| 6 | #include <string> | ||
| 7 | #include <cstddef> | ||
| 8 | |||
| 9 | #include "util/posix.h" | ||
| 10 | |||
| 11 | 248 | RaiiTempDir *RaiiTempDir::Create(const std::string &prefix) { | |
| 12 |
1/2✓ Branch 2 taken 248 times.
✗ Branch 3 not taken.
|
248 | RaiiTempDir *tmp = new RaiiTempDir(prefix); |
| 13 |
2/4✓ Branch 2 taken 248 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 248 times.
✗ Branch 6 not taken.
|
248 | if (tmp->dir() != "") { |
| 14 | 248 | return tmp; | |
| 15 | } else { | ||
| 16 | ✗ | delete tmp; | |
| 17 | ✗ | return NULL; | |
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | 248 | RaiiTempDir::RaiiTempDir(const std::string &prefix) | |
| 22 | 248 | : dir_(CreateTempDir(prefix)) { } | |
| 23 | |||
| 24 | 248 | RaiiTempDir::~RaiiTempDir() { RemoveTree(dir_); } | |
| 25 |