util: add file_locker class

This commit is contained in:
stoffu 2018-06-21 17:19:16 +09:00
parent 1d176473e9
commit 59de6f8d99
No known key found for this signature in database
GPG key ID: 41DAB8343A9EC012
2 changed files with 81 additions and 0 deletions

View file

@ -91,6 +91,20 @@ namespace tools
const std::string& filename() const noexcept { return m_filename; }
};
class file_locker
{
public:
file_locker(const std::string &filename);
~file_locker();
bool locked() const;
private:
#ifdef WIN32
HANDLE m_fd;
#else
int m_fd;
#endif
};
/*! \brief Returns the default data directory.
*
* \details Windows < Vista: C:\\Documents and Settings\\Username\\Application Data\\CRYPTONOTE_NAME