fix: handle partial reads

This commit is contained in:
2026-05-16 15:34:09 +02:00
parent 43ce38f2f4
commit fbd73ebf4c
+8 -1
View File
@@ -26,6 +26,7 @@ bool file_should_update(const File *file) {
bool file_update(File *file) {
long length;
size_t read_length;
FILE *file_pointer;
// free remaining data
@@ -63,7 +64,13 @@ bool file_update(File *file) {
return false;
}
// read file
fread(file->content, sizeof(char), length, file_pointer);
read_length = fread(file->content, sizeof(char), length, file_pointer);
if (read_length != length) {
file->error = true;
fclose(file_pointer);
log_error("Cannot read complete file '%s'", file->path);
return false;
}
// close file
fclose(file_pointer);
// append null byte