1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2025-01-31 20:41:45 +01:00

Simplify fs::file::get_handle

Via fs::file_base::get_native_handle method
This commit is contained in:
Nekotekina 2019-04-07 23:46:00 +03:00
parent 9736773c04
commit a54d9c527f
2 changed files with 16 additions and 12 deletions

View File

@ -192,6 +192,15 @@ namespace fs
// Do notning // Do notning
} }
native_handle file_base::get_native_handle()
{
#ifdef _WIN32
return INVALID_HANDLE_VALUE;
#else
return -1;
#endif
}
dir_base::~dir_base() dir_base::~dir_base()
{ {
} }
@ -884,7 +893,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
return; return;
} }
class windows_file final : public file_base, public get_native_handle class windows_file final : public file_base
{ {
const HANDLE m_handle; const HANDLE m_handle;
@ -987,7 +996,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
return size.QuadPart; return size.QuadPart;
} }
native_handle get() override native_handle get_native_handle() override
{ {
return m_handle; return m_handle;
} }
@ -1034,7 +1043,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
::ftruncate(fd, 0); ::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; const int m_fd;
@ -1127,7 +1136,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
return file_info.st_size; return file_info.st_size;
} }
native_handle get() override native_handle get_native_handle() override
{ {
return m_fd; 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 fs::native_handle fs::file::get_handle() const
{ {
if (auto getter = dynamic_cast<get_native_handle*>(m_file.get())) if (m_file)
{ {
return getter->get(); return m_file->get_native_handle();
} }
#ifdef _WIN32 #ifdef _WIN32

View File

@ -65,12 +65,6 @@ namespace fs
s64 ctime; s64 ctime;
}; };
// Native handle getter
struct get_native_handle
{
virtual native_handle get() = 0;
};
// File handle base // File handle base
struct file_base struct file_base
{ {
@ -83,6 +77,7 @@ namespace fs
virtual u64 write(const void* buffer, u64 size) = 0; virtual u64 write(const void* buffer, u64 size) = 0;
virtual u64 seek(s64 offset, seek_mode whence) = 0; virtual u64 seek(s64 offset, seek_mode whence) = 0;
virtual u64 size() = 0; virtual u64 size() = 0;
virtual native_handle get_native_handle();
}; };
// Directory entry (TODO) // Directory entry (TODO)