#include <util.h>
Definition at line 95 of file util.h.
◆ file_locker()
| tools::file_locker::file_locker |
( |
const std::string & |
filename | ) |
|
Definition at line 238 of file util.cpp.
241 m_fd = INVALID_HANDLE_VALUE;
245 filename_wide = string_tools::utf8_to_utf16(filename);
247 catch (
const std::exception &e)
249 MERROR(
"Failed to convert path \"" << filename <<
"\" to UTF-16: " << e.what());
252 m_fd = CreateFileW(filename_wide.c_str(), GENERIC_READ, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
253 if (m_fd != INVALID_HANDLE_VALUE)
256 memset(&ov, 0,
sizeof(ov));
257 if (!LockFileEx(m_fd, LOCKFILE_FAIL_IMMEDIATELY | LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &ov))
259 MERROR(
"Failed to lock " << filename <<
": " << std::error_code(GetLastError(), std::system_category()));
261 m_fd = INVALID_HANDLE_VALUE;
266 MERROR(
"Failed to open " << filename <<
": " << std::error_code(GetLastError(), std::system_category()));
269 m_fd = open(filename.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0666);
272 if (flock_exnb(m_fd) == -1)
274 MERROR(
"Failed to lock " << filename <<
": " << std::strerror(errno));
281 MERROR(
"Failed to open " << filename <<
": " << std::strerror(errno));
◆ ~file_locker()
| tools::file_locker::~file_locker |
( |
| ) |
|
◆ locked()
| bool tools::file_locker::locked |
( |
| ) |
const |
Definition at line 296 of file util.cpp.
299 return m_fd != INVALID_HANDLE_VALUE;
The documentation for this class was generated from the following files:
- /home/abuild/rpmbuild/BUILD/electroneum-5.0.0.4/src/common/util.h
- /home/abuild/rpmbuild/BUILD/electroneum-5.0.0.4/src/common/util.cpp