mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
Introduce coroutine support (util/coro.hpp)
Implement coroutine types `lazy` and `generator` in stx namespace. Implement fs::list_dir_recursively.
This commit is contained in:
parent
d6420b8803
commit
6b40d69a8f
4 changed files with 409 additions and 1 deletions
|
@ -9,6 +9,7 @@
|
|||
#include <map>
|
||||
|
||||
#include "util/asm.hpp"
|
||||
#include "util/coro.hpp"
|
||||
|
||||
using namespace std::literals::string_literals;
|
||||
|
||||
|
@ -1182,7 +1183,7 @@ fs::file::file(const std::string& path, bs_t<open_mode> mode)
|
|||
|
||||
for (const char* data = static_cast<const char*>(buffer); count;)
|
||||
{
|
||||
const DWORD size = static_cast<DWORD>(std::min<u64>(count, DWORD{umax} & -4096));
|
||||
const DWORD size = static_cast<DWORD>(std::min<u64>(count, DWORD{umax} & -4096));
|
||||
|
||||
DWORD nwritten = 0;
|
||||
ensure(WriteFile(m_handle, data, size, &nwritten, nullptr)); // "file::write"
|
||||
|
@ -2039,6 +2040,30 @@ bool fs::pending_file::commit(bool overwrite)
|
|||
return false;
|
||||
}
|
||||
|
||||
stx::generator<fs::dir_entry&> fs::list_dir_recursively(std::string path)
|
||||
{
|
||||
for (auto& entry : fs::dir(path))
|
||||
{
|
||||
if (entry.name == "." || entry.name == "..")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string new_path = path_append(path, entry.name);
|
||||
|
||||
if (entry.is_directory)
|
||||
{
|
||||
for (auto& nested : fs::list_dir_recursively(new_path))
|
||||
{
|
||||
co_yield nested;
|
||||
}
|
||||
}
|
||||
|
||||
entry.name = std::move(new_path);
|
||||
co_yield entry;
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
void fmt_class_string<fs::seek_mode>::format(std::string& out, u64 arg)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue