mirror of
https://github.com/Tha14/toxic.git
synced 2024-11-13 03:33:03 +01:00
use 64-bit off_t for file sizes
This commit is contained in:
parent
893e88294b
commit
a432d733d7
@ -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)
|
||||
|
@ -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.");
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user