diff --git a/build/Makefile b/build/Makefile index 33a4752..672f711 100644 --- a/build/Makefile +++ b/build/Makefile @@ -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) diff --git a/src/chat_commands.c b/src/chat_commands.c index 00d576f..62d8b62 100644 --- a/src/chat_commands.c +++ b/src/chat_commands.c @@ -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."); diff --git a/src/friendlist.c b/src/friendlist.c index 67fcd85..0f0c88e 100644 --- a/src/friendlist.c +++ b/src/friendlist.c @@ -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); diff --git a/src/log.c b/src/log.c index d727870..b73b2df 100644 --- a/src/log.c +++ b/src/log.c @@ -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); diff --git a/src/misc_tools.c b/src/misc_tools.c index 8b928c4..c7ecf0e 100644 --- a/src/misc_tools.c +++ b/src/misc_tools.c @@ -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; } diff --git a/src/misc_tools.h b/src/misc_tools.h index e6f66a2..472fdfe 100644 --- a/src/misc_tools.h +++ b/src/misc_tools.h @@ -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 */ diff --git a/src/toxic.c b/src/toxic.c index bc20bea..126fef3 100644 --- a/src/toxic.c +++ b/src/toxic.c @@ -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);