diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 745fb35ac1..2ed5ac4500 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -192,6 +192,15 @@ namespace fs // Do notning } + native_handle file_base::get_native_handle() + { +#ifdef _WIN32 + return INVALID_HANDLE_VALUE; +#else + return -1; +#endif + } + dir_base::~dir_base() { } @@ -884,7 +893,7 @@ fs::file::file(const std::string& path, bs_t mode) return; } - class windows_file final : public file_base, public get_native_handle + class windows_file final : public file_base { const HANDLE m_handle; @@ -987,7 +996,7 @@ fs::file::file(const std::string& path, bs_t mode) return size.QuadPart; } - native_handle get() override + native_handle get_native_handle() override { return m_handle; } @@ -1034,7 +1043,7 @@ fs::file::file(const std::string& path, bs_t mode) ::ftruncate(fd, 0); } - class unix_file final : public file_base, public get_native_handle + class unix_file final : public file_base { const int m_fd; @@ -1127,7 +1136,7 @@ fs::file::file(const std::string& path, bs_t mode) return file_info.st_size; } - native_handle get() override + native_handle get_native_handle() override { return m_fd; } @@ -1208,9 +1217,9 @@ fs::file::file(const void* ptr, std::size_t size) fs::native_handle fs::file::get_handle() const { - if (auto getter = dynamic_cast(m_file.get())) + if (m_file) { - return getter->get(); + return m_file->get_native_handle(); } #ifdef _WIN32 diff --git a/Utilities/File.h b/Utilities/File.h index 652b2cf4d8..ef4db36ff6 100644 --- a/Utilities/File.h +++ b/Utilities/File.h @@ -65,12 +65,6 @@ namespace fs s64 ctime; }; - // Native handle getter - struct get_native_handle - { - virtual native_handle get() = 0; - }; - // File handle base struct file_base { @@ -83,6 +77,7 @@ namespace fs virtual u64 write(const void* buffer, u64 size) = 0; virtual u64 seek(s64 offset, seek_mode whence) = 0; virtual u64 size() = 0; + virtual native_handle get_native_handle(); }; // Directory entry (TODO)