MCPcopy Create free account
hub / github.com/GarageGames/Torque3D / read

Method read

Engine/source/platformWin32/winFileio.cpp:514–537  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Read from a file. The number of bytes to read is passed in size, the data is returned in src. The number of bytes read is available in bytesRead if a non-Null pointer is provided. -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

512// provided.
513//-----------------------------------------------------------------------------
514File::FileStatus File::read(U32 size, char *dst, U32 *bytesRead)
515{
516 AssertFatal(Closed != currentStatus, "File::read: file closed");
517 AssertFatal(INVALID_HANDLE_VALUE != (HANDLE)handle, "File::read: invalid file handle");
518 AssertFatal(NULL != dst, "File::read: NULL destination pointer");
519 AssertFatal(true == hasCapability(FileRead), "File::read: file lacks capability");
520 AssertWarn(0 != size, "File::read: size of zero");
521
522 if (Ok != currentStatus || 0 == size)
523 return currentStatus;
524 else
525 {
526 DWORD lastBytes;
527 DWORD *bytes = (NULL == bytesRead) ? &lastBytes : (DWORD *)bytesRead;
528 if (0 != ReadFile((HANDLE)handle, dst, size, bytes, NULL))
529 {
530 if(*((U32 *)bytes) != size)
531 return currentStatus = EOS; // end of stream
532 }
533 else
534 return setStatus(); // unsuccessful
535 }
536 return currentStatus = Ok; // successfully read size bytes
537}
538
539//-----------------------------------------------------------------------------
540// Write to a file.

Callers

nothing calls this directly

Calls 1

ReadFileFunction · 0.85

Tested by

no test coverage detected