1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
*/ |
4 |
|
|
|
5 |
|
|
#ifndef CVMFS_UTIL_RAII_TEMP_DIR_H_ |
6 |
|
|
#define CVMFS_UTIL_RAII_TEMP_DIR_H_ |
7 |
|
|
|
8 |
|
|
#include <string> |
9 |
|
|
|
10 |
|
|
/** |
11 |
|
|
* RAII based temporary directory helper class |
12 |
|
|
* |
13 |
|
|
* Instances of the class create a temporary directory which is then |
14 |
|
|
* deleted by the destructor of the class. |
15 |
|
|
* |
16 |
|
|
* The temporary directory is created using the given prefix string |
17 |
|
|
* ("prefix.<UNIQUE_SUFFIX>") |
18 |
|
|
*/ |
19 |
|
|
class RaiiTempDir { |
20 |
|
|
public: |
21 |
|
|
static RaiiTempDir* Create(const std::string& prefix); |
22 |
|
|
|
23 |
|
22 |
std::string dir() const { return dir_; } |
24 |
|
|
|
25 |
|
|
~RaiiTempDir(); |
26 |
|
|
|
27 |
|
|
private: |
28 |
|
|
explicit RaiiTempDir(const std::string& prefix); |
29 |
|
|
|
30 |
|
|
std::string dir_; |
31 |
|
|
}; |
32 |
|
|
|
33 |
|
|
#endif // CVMFS_UTIL_RAII_TEMP_DIR_H_ |