1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-12-22 23:03:25 +01:00

use 64-bit off_t for file sizes

This commit is contained in:
Jfreegman 2014-09-24 14:23:08 -04:00
parent 893e88294b
commit a432d733d7
No known key found for this signature in database
GPG Key ID: 3627F3144076AE63
7 changed files with 9 additions and 9 deletions

View File

@ -6,7 +6,7 @@ CFG_DIR = $(BASE_DIR)/cfg
LIBS = libtoxcore ncursesw libconfig
CFLAGS = -std=gnu99 -pthread -Wall -g
CFLAGS += '-DTOXICVER="$(VERSION)"' -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED
CFLAGS += '-DTOXICVER="$(VERSION)"' -DHAVE_WIDECHAR -D_XOPEN_SOURCE_EXTENDED -D_FILE_OFFSET_BITS=64
CFLAGS += '-DPACKAGE_DATADIR="$(abspath $(DATADIR))"'
CFLAGS += $(USER_CFLAGS)
LDFLAGS = $(USER_LDFLAGS)

View File

@ -224,7 +224,7 @@ void cmd_sendfile(WINDOW *window, ToxWindow *self, Tox *m, int argc, char (*argv
return;
}
uint64_t filesize = file_size(path);
off_t filesize = file_size(path);
if (filesize == -1) {
line_info_add(self, NULL, NULL, NULL, SYS_MSG, 0, 0, "File corrupt.");

View File

@ -181,7 +181,7 @@ int load_blocklist(char *path)
if (fp == NULL)
return -1;
uint64_t len = file_size(path);
off_t len = file_size(path);
if (len == -1) {
fclose(fp);

View File

@ -156,9 +156,9 @@ void load_chat_history(ToxWindow *self, struct chatlog *log)
if (log->file == NULL)
return;
uint64_t sz = file_size(log->path);
off_t sz = file_size(log->path);
if (sz <= 0)
if (sz == 0)
return;
char *hstbuf = malloc(sz);

View File

@ -313,12 +313,12 @@ bool file_exists(const char *path)
}
/* returns file size or -1 on error */
uint64_t file_size(const char *path)
off_t file_size(const char *path)
{
struct stat st;
if (stat(path, &st) == -1)
return -1;
return (uint64_t) st.st_size;
return st.st_size;
}

View File

@ -113,6 +113,6 @@ void bytes_convert_str(char *buf, int size, uint64_t bytes);
bool file_exists(const char *path);
/* returns file size or -1 on error */
uint64_t file_size(const char *path);
off_t file_size(const char *path);
#endif /* #define MISC_TOOLS_H */

View File

@ -629,7 +629,7 @@ static void load_data(Tox *m, char *path)
FILE *fd;
if ((fd = fopen(path, "rb")) != NULL) {
uint64_t len = file_size(path);
off_t len = file_size(path);
if (len == -1) {
fclose(fd);