MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / fdReaddir

Method fdReaddir

lib/host/wasi/inode-win.cpp:1084–1122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1082}
1083
1084WasiExpect<void> INode::fdReaddir(Span<uint8_t> Buffer,
1085 __wasi_dircookie_t Cookie,
1086 __wasi_size_t &Size) noexcept {
1087 if (likely(Find.ok())) {
1088 EXPECTED_TRY(Find.seek(Cookie));
1089 }
1090
1091 if (unlikely(!Find.ok())) {
1092 // Begin the search for files
1093 EXPECTED_TRY(Find.emplace(Handle));
1094 }
1095
1096 bool FindNextResult = true;
1097 Size = 0;
1098
1099 do {
1100 const auto Written = Find.write(Buffer);
1101 Buffer = Buffer.subspan(Written);
1102 Size += static_cast<uint32_t>(Written);
1103 if (unlikely(Buffer.empty())) {
1104 break;
1105 }
1106 if (!FindNextResult) {
1107 // Check whether there are no more files left or an error was encountered.
1108 if (DWORD_ Code = GetLastError();
1109 unlikely(Code != ERROR_NO_MORE_FILES_)) {
1110 // The FindNextFileW() function failed.
1111 return WasiUnexpect(detail::fromLastError(Code));
1112 }
1113 break;
1114 }
1115
1116 EXPECTED_TRY(Find.loadDirent());
1117
1118 FindNextResult = Find.next();
1119 } while (!Buffer.empty());
1120
1121 return {};
1122}
1123
1124WasiExpect<void> INode::fdSeek(__wasi_filedelta_t Offset,
1125 __wasi_whence_t Whence,

Callers 1

bodyMethod · 0.45

Calls 13

unlikelyFunction · 0.85
WasiUnexpectFunction · 0.85
fromLastErrorFunction · 0.85
subspanMethod · 0.80
loadDirentMethod · 0.80
likelyFunction · 0.50
EXPECTED_TRYFunction · 0.50
okMethod · 0.45
seekMethod · 0.45
emplaceMethod · 0.45
writeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected