mirror of
https://github.com/gbdev/rgbds.git
synced 2026-11-22 05:48:39 +00:00
Use std::optional<uint64_t> instead of long with a special -1 sentinel for seekSize
This commit is contained in:
1 parent
c3073f4318
commit
c691ec6607
5 files changed
+29
-26
No files matched your search
+5
-5
@@ -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) {
|
||||
|
||||
Reference in new issue
Block a user