mirror of
https://github.com/Tha14/toxic.git
synced 2025-12-18 08:36:35 +01:00
more succinct way to get file sizes
This commit is contained in:
12
src/toxic.c
12
src/toxic.c
@@ -629,23 +629,13 @@ static void load_data(Tox *m, char *path)
|
||||
FILE *fd;
|
||||
|
||||
if ((fd = fopen(path, "rb")) != NULL) {
|
||||
if (fseek(fd, 0L, SEEK_END) == -1) {
|
||||
fclose(fd);
|
||||
exit_toxic_err("failed in load_data", FATALERR_FILEOP);
|
||||
}
|
||||
|
||||
int len = ftell(fd);
|
||||
uint64_t len = file_size(path);
|
||||
|
||||
if (len == -1) {
|
||||
fclose(fd);
|
||||
exit_toxic_err("failed in load_data", FATALERR_FILEOP);
|
||||
}
|
||||
|
||||
if (fseek(fd, 0L, SEEK_SET)) {
|
||||
fclose(fd);
|
||||
exit_toxic_err("failed in load_data", FATALERR_FILEOP);
|
||||
}
|
||||
|
||||
char *buf = malloc(len);
|
||||
|
||||
if (buf == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user