5 #ifndef CVMFS_UTIL_FILE_GUARD_H_
6 #define CVMFS_UTIL_FILE_GUARD_H_
15 #ifdef CVMFS_NAMESPACE_GUARD
16 namespace CVMFS_NAMESPACE_GUARD {
33 : path_(path), enabled_(state == kEnabled) { }
36 unlink(path_.c_str());
39 inline void Set(
const std::string &path) {
45 inline void Enable() { enabled_ =
true; }
46 inline void Disable() { enabled_ =
false; }
48 const std::string &
path()
const {
return path_; }
62 explicit inline FdGuard(
const int fd) : fd_(fd) { }
67 int fd()
const {
return fd_; }
80 explicit inline FileGuard(FILE *file) : file_(file) { }
85 const FILE *
file()
const {
return file_; }
92 #ifdef CVMFS_NAMESPACE_GUARD
96 #endif // CVMFS_UTIL_FILE_GUARD_H_
UnlinkGuard(const std::string &path, const InitialState state=kEnabled)
const std::string & path() const
const FILE * file() const
void Set(const std::string &path)