mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
fs::dir improved
FindFirstFileExW used Immediate directory read
This commit is contained in:
parent
c20756136a
commit
e3bc2273d3
1 changed files with 11 additions and 18 deletions
|
@ -932,7 +932,7 @@ bool fs::dir::open(const std::string& path)
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
WIN32_FIND_DATAW found;
|
WIN32_FIND_DATAW found;
|
||||||
const auto handle = FindFirstFileW(to_wchar(path + "/*").get(), &found);
|
const auto handle = FindFirstFileExW(to_wchar(path + "/*").get(), FindExInfoBasic, &found, FindExSearchNameMatch, NULL, FIND_FIRST_EX_CASE_SENSITIVE | FIND_FIRST_EX_LARGE_FETCH);
|
||||||
|
|
||||||
if (handle == INVALID_HANDLE_VALUE)
|
if (handle == INVALID_HANDLE_VALUE)
|
||||||
{
|
{
|
||||||
|
@ -942,8 +942,6 @@ bool fs::dir::open(const std::string& path)
|
||||||
|
|
||||||
class windows_dir final : public dir_base
|
class windows_dir final : public dir_base
|
||||||
{
|
{
|
||||||
const HANDLE m_handle;
|
|
||||||
|
|
||||||
std::vector<dir_entry> m_entries;
|
std::vector<dir_entry> m_entries;
|
||||||
std::size_t m_pos = 0;
|
std::size_t m_pos = 0;
|
||||||
|
|
||||||
|
@ -963,29 +961,24 @@ bool fs::dir::open(const std::string& path)
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
windows_dir(HANDLE handle, const WIN32_FIND_DATAW& found)
|
windows_dir(HANDLE handle, WIN32_FIND_DATAW& found)
|
||||||
: m_handle(handle)
|
|
||||||
{
|
{
|
||||||
add_entry(found);
|
add_entry(found);
|
||||||
}
|
|
||||||
|
|
||||||
~windows_dir()
|
while (FindNextFileW(handle, &found))
|
||||||
{
|
{
|
||||||
FindClose(m_handle);
|
add_entry(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
verify("dir::read" HERE), ERROR_NO_MORE_FILES == GetLastError();
|
||||||
|
FindClose(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool read(dir_entry& out) override
|
bool read(dir_entry& out) override
|
||||||
{
|
{
|
||||||
if (m_pos == m_entries.size())
|
if (m_pos >= m_entries.size())
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATAW found;
|
return false;
|
||||||
if (!FindNextFileW(m_handle, &found))
|
|
||||||
{
|
|
||||||
verify("dir::read" HERE), ERROR_NO_MORE_FILES == GetLastError();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
add_entry(found);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out = m_entries[m_pos++];
|
out = m_entries[m_pos++];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue