fix: Providers not compiling on Unix
This commit is contained in:
parent
a70ece7b9c
commit
a5a1ae6725
@ -47,6 +47,7 @@ namespace hex::plugin::builtin::prv {
|
|||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
HANDLE m_diskHandle = INVALID_HANDLE_VALUE;
|
HANDLE m_diskHandle = INVALID_HANDLE_VALUE;
|
||||||
#else
|
#else
|
||||||
|
std::string m_pathBuffer;
|
||||||
int m_diskHandle = -1;
|
int m_diskHandle = -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -103,15 +103,17 @@ namespace hex::plugin::builtin::prv {
|
|||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
const auto &path = this->m_path.native();
|
||||||
|
|
||||||
struct stat driveStat;
|
struct stat driveStat;
|
||||||
|
|
||||||
::stat(this->m_path.data(), &driveStat) == 0;
|
::stat(path.c_str(), &driveStat) == 0;
|
||||||
this->m_diskSize = driveStat.st_size;
|
this->m_diskSize = driveStat.st_size;
|
||||||
this->m_sectorSize = 0;
|
this->m_sectorSize = 0;
|
||||||
|
|
||||||
this->m_diskHandle = ::open(this->m_path.data(), O_RDWR);
|
this->m_diskHandle = ::open(path.c_str(), O_RDWR);
|
||||||
if (this->m_diskHandle == -1) {
|
if (this->m_diskHandle == -1) {
|
||||||
this->m_diskHandle = ::open(this->m_path.data(), O_RDONLY);
|
this->m_diskHandle = ::open(path.c_str(), O_RDONLY);
|
||||||
this->m_writable = false;
|
this->m_writable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +308,8 @@ namespace hex::plugin::builtin::prv {
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
ImGui::InputText("hex.builtin.provider.disk.selected_disk"_lang, this->m_path.data(), this->m_path.capacity(), ImGuiInputTextFlags_CallbackResize, ImGui::UpdateStringSizeCallback, &this->m_path);
|
if (ImGui::InputText("hex.builtin.provider.disk.selected_disk"_lang, this->m_pathBuffer.data(), this->m_pathBuffer.capacity(), ImGuiInputTextFlags_CallbackResize, ImGui::UpdateStringSizeCallback, &this->m_pathBuffer))
|
||||||
|
this->m_path = this->m_pathBuffer;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ namespace hex::plugin::builtin::prv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool FileProvider::open() {
|
bool FileProvider::open() {
|
||||||
this->m_fileStatsValid = stat(this->m_path.string().data(), &this->m_fileStats) == 0;
|
this->m_fileStatsValid = stat(this->m_path.string().c_str(), &this->m_fileStats) == 0;
|
||||||
|
|
||||||
this->m_readable = true;
|
this->m_readable = true;
|
||||||
this->m_writable = true;
|
this->m_writable = true;
|
||||||
@ -212,9 +212,11 @@ namespace hex::plugin::builtin::prv {
|
|||||||
fileCleanup.release();
|
fileCleanup.release();
|
||||||
|
|
||||||
#else
|
#else
|
||||||
this->m_file = ::open(this->m_path.data(), O_RDWR);
|
const auto &path = this->m_path.native();
|
||||||
|
|
||||||
|
this->m_file = ::open(path.c_str(), O_RDWR);
|
||||||
if (this->m_file == -1) {
|
if (this->m_file == -1) {
|
||||||
this->m_file = ::open(this->m_path.data(), O_RDONLY);
|
this->m_file = ::open(path.c_str(), O_RDONLY);
|
||||||
this->m_writable = false;
|
this->m_writable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,17 +240,17 @@ namespace hex::plugin::builtin::prv {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FileProvider::close() {
|
void FileProvider::close() {
|
||||||
#if defined(OS_WINDOWS)
|
#if defined(OS_WINDOWS)
|
||||||
if (this->m_mappedFile != nullptr)
|
if (this->m_mappedFile != nullptr)
|
||||||
::UnmapViewOfFile(this->m_mappedFile);
|
::UnmapViewOfFile(this->m_mappedFile);
|
||||||
if (this->m_mapping != nullptr)
|
if (this->m_mapping != nullptr)
|
||||||
::CloseHandle(this->m_mapping);
|
::CloseHandle(this->m_mapping);
|
||||||
if (this->m_file != nullptr)
|
if (this->m_file != nullptr)
|
||||||
::CloseHandle(this->m_file);
|
::CloseHandle(this->m_file);
|
||||||
#else
|
#else
|
||||||
::munmap(this->m_mappedFile, this->m_fileSize);
|
::munmap(this->m_mappedFile, this->m_fileSize);
|
||||||
::close(this->m_file);
|
::close(this->m_file);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user