1
0
mirror of https://github.com/Tha14/toxic.git synced 2025-07-06 09:26:44 +02: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

@ -224,13 +224,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
return;
}
if (fseek(file_to_send, 0, SEEK_END) == -1) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File corrupt.");
fclose(file_to_send);
return;
}
uint64_t filesize = ftell(file_to_send);
uint64_t filesize = file_size(path);
if (filesize == -1) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File corrupt.");
@ -238,12 +232,6 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
return;
}
if (fseek(file_to_send, 0, SEEK_SET) == -1) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File corrupt.");
fclose(file_to_send);
return;
}
char filename[MAX_STR_SIZE] = {0};
get_file_name(filename, sizeof(filename), path);
int namelen = strlen(filename);