FileTell
Description
Return the current file offset.
Success
Returns the offset (>= 0).
Failure
Returns -1 on error.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
File.c:342:
}
i64 FileTell(File *f) {
return FileSeek(f, 0, FILE_SEEK_CUR);
}- In
File.c:126:
ok = ok && (FileWrite(&f, "x", 1) == -1);
ok = ok && (FileSeek(&f, 0, FILE_SEEK_SET) == -1);
ok = ok && (FileTell(&f) == -1);
FileRemove(&path);- In
File.c:169:
// observable values.
bool test_write_seek_read_roundtrip(void) {
WriteFmt("Testing FileWrite/FileSeek/FileTell/FileRead round-trip\n");
DefaultAllocator alloc = DefaultAllocatorInit();- In
File.c:186:
// After writing 8 bytes the cursor is at offset 8.
ok = ok && (FileTell(&f) == 8);
// Seek to absolute offset 2 and confirm Tell agrees.
- In
File.c:190:
// Seek to absolute offset 2 and confirm Tell agrees.
ok = ok && (FileSeek(&f, 2, FILE_SEEK_SET) == 2);
ok = ok && (FileTell(&f) == 2);
char got[4] = {0};- In
File.c:197:
// Cursor advanced by the 4 read bytes (2 -> 6).
ok = ok && (FileTell(&f) == 6);
// Seek to end yields the file length.
- In
Write.c:4198:
ok = ok && (v == 42);
// Seekable branch advances to exactly the consumed bytes ("42").
ok = ok && (FileTell(&f) == 2);
m4_cleanup(&f, &path);- In
Write.c:4247:
FReadFmt(&f, "{}", v);
ok = ok && (v == 53);
ok = ok && (FileTell(&f) == 2);
m4_cleanup(&f, &path);- In
Read.c:1680:
FReadFmt(&f, "{}", v);
ok = ok && (v == 1234); // untouched
ok = ok && (FileTell(&f) == 0); // no advance
m4_cleanup(&f, &path);
Last updated on