Update read_entrie_file function

This commit is contained in:
Abdelrahman Said 2023-10-21 19:58:49 +01:00
parent 05e5a9ca21
commit cb9b6fd4dc
2 changed files with 4 additions and 2 deletions

View File

@ -16,7 +16,7 @@ typedef struct {
} dirwalk_result_t; } dirwalk_result_t;
u64 get_file_length(FILE *fp); u64 get_file_length(FILE *fp);
void read_entire_file(void *dst, u64 length, FILE *fp); void read_entire_file(void *dst, FILE *fp);
dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath); dirwalk_result_t walk_dir(dirwalk_t **dirwalk, const char *filepath);
#endif // !IO_H #endif // !IO_H

View File

@ -33,7 +33,9 @@ u64 get_file_length(FILE *fp) {
return length; return length;
} }
void read_entire_file(void *dst, u64 length, FILE *fp) { void read_entire_file(void *dst, FILE *fp) {
u64 length = get_file_length(fp);
u64 current = ftell(fp); u64 current = ftell(fp);
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);