MCPcopy Create free account
hub / github.com/crownengine/crown / read

Method read

src/core/process.cpp:241–280  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241char *Process::read(u32 *num_bytes_read, char *data, u32 len)
242{
243 CE_ENSURE(process_internal::is_open(_priv) == true);
244#if CROWN_PLATFORM_WINDOWS
245 DWORD read;
246 BOOL success = FALSE;
247
248 success = ReadFile(_priv->stdout_rd, data, len, &read, NULL);
249 if (!success) {
250 *num_bytes_read = UINT32_MAX;
251 return NULL;
252 }
253
254 if (read == 0) {
255 // EOF
256 *num_bytes_read = 0;
257 return NULL;
258 } else {
259 *num_bytes_read = read;
260 return data;
261 }
262#else
263 CE_ENSURE(_priv->file != NULL);
264 size_t read = fread(data, 1, len, _priv->file);
265 if (read != len) {
266 if (feof(_priv->file) != 0) {
267 if (read == 0) {
268 *num_bytes_read = 0;
269 return NULL;
270 }
271 } else if (ferror(_priv->file) != 0) {
272 *num_bytes_read = UINT32_MAX;
273 return NULL;
274 }
275 }
276
277 *num_bytes_read = read;
278 return data;
279#endif // if CROWN_PLATFORM_WINDOWS
280}
281
282} // namespace crown

Callers 3

test_processFunction · 0.45
loadMethod · 0.45
decode_samplesMethod · 0.45

Calls 4

is_openFunction · 0.85
freadFunction · 0.85
feofFunction · 0.85
ferrorFunction · 0.85

Tested by 1

test_processFunction · 0.36