1
0
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:
Jfreegman
2014-09-24 00:06:02 -04:00
parent b071a9e992
commit 893e88294b
6 changed files with 18 additions and 43 deletions

View File

@@ -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) {