mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-17 08:11:51 +00:00
Simplify fs::file::get_handle
Via fs::file_base::get_native_handle method
This commit is contained in:
parent
9736773c04
commit
a54d9c527f
@ -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<open_mode> 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<open_mode> 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<open_mode> 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<open_mode> 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<get_native_handle*>(m_file.get()))
|
||||
if (m_file)
|
||||
{
|
||||
return getter->get();
|
||||
return m_file->get_native_handle();
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user