Skip to content

Commit

Permalink
sanitise large file support
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterMute authored and fincs committed May 8, 2018
1 parent d2a2a3d commit 48d96a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AC_CANONICAL_HOST

AC_PROG_CC

AC_SYS_LARGEFILE

PKG_CHECK_MODULES([LZ4],
[liblz4 >= 1.7.1 liblz4 < 100],
Expand Down
19 changes: 5 additions & 14 deletions src/filepath.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include <wchar.h>
#endif

#define __USE_LARGEFILE64

#define MAX_SWITCHPATH 0x300

typedef enum {
Expand All @@ -22,16 +20,9 @@ inline int fseeko64(FILE *__stream, long long __off, int __whence)
{
return _fseeki64(__stream, __off, __whence);
}
#elif __APPLE__ || __CYGWIN__
// OS X file I/O is 64bit
#define fseeko64 fseek
#elif __linux__
extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
#else
/* fseeko is guaranteed by POSIX, hopefully the OS made their off_t definition 64-bit;
* known sane on FreeBSD and OpenBSD.
*/
#define fseeko64 fseeko
/* off_t is 64-bit with large file support */
#define fseeko64 fseek
#endif

#ifdef _WIN32
Expand All @@ -53,12 +44,12 @@ typedef struct _stati64 os_stat64_t;
typedef char oschar_t; /* utf-8 */
typedef DIR osdir_t;
typedef struct dirent osdirent_t;
typedef struct stat64 os_stat64_t;
typedef struct stat os_stat64_t;

#define os_fopen fopen
#define os_opendir opendir
#define os_readdir readdir
#define os_stat stat64
#define os_stat stat
#define os_fclose fclose

#define OS_MODE_READ "rb"
Expand All @@ -85,4 +76,4 @@ void filepath_os_append(filepath_t *fpath, oschar_t *path);
void filepath_append(filepath_t *fpath, const char *format, ...);
void filepath_append_n(filepath_t *fpath, uint32_t n, const char *format, ...);
void filepath_set(filepath_t *fpath, const char *path);
oschar_t *filepath_get(filepath_t *fpath);
oschar_t *filepath_get(filepath_t *fpath);

0 comments on commit 48d96a7

Please sign in to comment.