FileSeek
Description
Adjust the file offset relative to whence.
Success
Returns the new absolute file offset (>= 0).
Failure
Returns -1 on error (typically ESPIPE for a pipe/tty).
Usage example (Cross-references)
Usage examples (Cross-references)
- In
Io.c:770:
// channel is positionable; if it returns -1 (ESPIPE / Windows
// equivalent) treat the input as a stream and pull bytes until EOF.
i64 probe = FileSeek(file, 0, FILE_SEEK_CUR);
if (probe < 0 || fd == 0 || fd == 1 || fd == 2) {
LOG_INFO("Reading from non-seekable channel.");- In
Io.c:783:
// actually consumed".
i64 cur_pos = probe;
i64 end_pos = FileSeek(file, 0, FILE_SEEK_END);
if (end_pos < 0) {
LOG_ERROR("FileSeek(END) failed during f_read_fmt");- In
Io.c:785:
i64 end_pos = FileSeek(file, 0, FILE_SEEK_END);
if (end_pos < 0) {
LOG_ERROR("FileSeek(END) failed during f_read_fmt");
StrDeinit(&buffer);
DefaultAllocatorDeinit(&scratch);- In
Io.c:791:
}
i64 file_len = end_pos - cur_pos;
(void)FileSeek(file, cur_pos, FILE_SEEK_SET);
if (file_len > 0) {- In
Io.c:809:
if (!new_pos) {
LOG_ERROR("Parse failed, rolling back...");
(void)FileSeek(file, cur_pos, FILE_SEEK_SET);
} else {
// Advance the channel position past the bytes we consumed.
- In
Io.c:813:
// Advance the channel position past the bytes we consumed.
i64 consumed = (i64)(new_pos - buffer.data);
(void)FileSeek(file, cur_pos + consumed, FILE_SEEK_SET);
}
}- In
File.c:291:
}
i64 FileSeek(File *f, i64 offset, FileWhence whence) {
if (!FileIsValid(f)) {
return -1;- In
File.c:321:
i64 FileTell(File *f) {
return FileSeek(f, 0, FILE_SEEK_CUR);
}- In
ElfInfo.c:352:
// technically padding here but we can skip it
FileSeek(&elf, 7, FILE_SEEK_CUR);
// XXX: For now we only support x86_64 binaries
Last updated on