Use std::optional<uint64_t> instead of long with a special -1 sentinel for seekSize

This commit is contained in:
Rangi committed 2026-07-21 14:31:05 -04:00
1 parent c3073f4318
commit c691ec6607
5 files changed
+29 -26

No files matched your search

+5 -5
View File
@@ -25,18 +25,18 @@ int xclose(int fd) {
return close(fd);
}
long seekSize(FILE *file) {
std::optional<uint64_t> seekSize(FILE *file) {
if (fseek(file, 0, SEEK_END) != 0) {
return -1;
return std::nullopt;
}
long size = ftell(file);
if (size < 0) {
return -1;
return std::nullopt;
}
if (fseek(file, 0, SEEK_SET) != 0) {
return -1;
return std::nullopt;
}
return size;
return static_cast<uint64_t>(size);
}
bool isNewline(int c) {