mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 15:09:59 +01:00
add unicode compatible file_lock for Windows
boost::interprocess::file_lock cannot open the files that contain characters which cannot be parsed by the user's code page on Windows. This commit add a new class to handle those specific file for Windows.
This commit is contained in:
20
src/fs.h
20
src/fs.h
@@ -19,6 +19,26 @@ namespace fs = boost::filesystem;
|
||||
namespace fsbridge {
|
||||
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
|
||||
void* hFile = (void*)-1; // INVALID_HANDLE_VALUE
|
||||
#endif
|
||||
};
|
||||
};
|
||||
|
||||
#endif // BITCOIN_FS_H
|
||||
|
||||
Reference in New Issue
Block a user