FileRead
Description
Read up to n bytes into buf. Short reads are normal at EOF and on signal interruption (we don’t retry on EINTR for you – callers that need that should loop). Sets the at_eof flag when the syscall reports zero bytes.
Success
Returns the number of bytes read (>= 0).
Failure
Returns -1 on error.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
ProcMaps.c:189:
return false;
}
i64 n = FileRead(&f, out->raw.data + out->raw.length, CHUNK);
if (n < 0) {
LOG_ERROR("ProcMapsLoad: FileRead failed");- In
ProcMaps.c:191:
i64 n = FileRead(&f, out->raw.data + out->raw.length, CHUNK);
if (n < 0) {
LOG_ERROR("ProcMapsLoad: FileRead failed");
FileClose(&f);
ProcMapsDeinit(out);- In
Io.c:774:
LOG_INFO("Reading from non-seekable channel.");
char buf_byte = 0;
while (FileRead(file, &buf_byte, 1) == 1) {
StrPushBack(&buffer, buf_byte);
}- In
Io.c:795:
if (file_len > 0) {
StrReserve(&buffer, (u64)file_len);
i64 got = FileRead(file, buffer.data, (u64)file_len);
if (got < 0) {
LOG_ERROR("FileRead failed during f_read_fmt");- In
Io.c:797:
i64 got = FileRead(file, buffer.data, (u64)file_len);
if (got < 0) {
LOG_ERROR("FileRead failed during f_read_fmt");
StrDeinit(&buffer);
DefaultAllocatorDeinit(&scratch);- In
File.c:226:
// ---------------------------------------------------------------------------
i64 FileRead(File *f, void *buf, u64 n) {
if (!FileIsValid(f) || !buf) {
return -1;- In
File.c:388:
}
i64 got = FileRead(&f, buffer, (u64)fsize);
FileClose(&f);
if (got != fsize) {
Last updated on