Changeset View
Changeset View
Standalone View
Standalone View
src/fs.h
Show All 11 Lines | |||||
#include <boost/filesystem/fstream.hpp> | #include <boost/filesystem/fstream.hpp> | ||||
/** Filesystem operations and types */ | /** Filesystem operations and types */ | ||||
namespace fs = boost::filesystem; | namespace fs = boost::filesystem; | ||||
/** Bridge operations to C stdio */ | /** Bridge operations to C stdio */ | ||||
namespace fsbridge { | namespace fsbridge { | ||||
FILE *fopen(const fs::path &p, const char *mode); | FILE *fopen(const fs::path &p, const char *mode); | ||||
FILE *freopen(const fs::path &p, const char *mode, FILE *stream); | |||||
class FileLock { | |||||
public: | |||||
FileLock() = delete; | |||||
FileLock(const FileLock &) = delete; | |||||
FileLock(FileLock &&) = delete; | |||||
explicit FileLock(const fs::path &file); | |||||
~FileLock(); | |||||
bool TryLock(); | |||||
std::string GetReason() { return reason; } | |||||
private: | |||||
std::string reason; | |||||
#ifndef WIN32 | |||||
int fd = -1; | |||||
#else | |||||
// INVALID_HANDLE_VALUE | |||||
void *hFile = (void *)-1; | |||||
#endif | |||||
}; | |||||
}; // namespace fsbridge | }; // namespace fsbridge | ||||
#endif // BITCOIN_FS_H | #endif // BITCOIN_FS_H |