Skip to content

Commit

Permalink
Change qfileofs_t from long long to int64_t
Browse files Browse the repository at this point in the history
(plus add explicit casts and compile_time asserts for Windows)
  • Loading branch information
andrei-drexler authored and vsonnier committed Jul 17, 2024
1 parent b9d9f76 commit 25986df
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Quake/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void Sys_Init (void);
// file IO
//

typedef long long qfileofs_t;
typedef int64_t qfileofs_t;

int Sys_fseek (FILE *file, qfileofs_t ofs, int origin);
qfileofs_t Sys_ftell (FILE *file);
Expand Down
4 changes: 2 additions & 2 deletions Quake/sys_sdl_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ COMPILE_TIME_ASSERT (CHECK_LARGE_FILE_SUPPORT, sizeof (off_t) >= sizeof (qfileof

int Sys_fseek (FILE *file, qfileofs_t ofs, int origin)
{
return fseeko (file, ofs, origin);
return fseeko (file, (off_t)ofs, origin);
}

qfileofs_t Sys_ftell (FILE *file)
{
return ftello (file);
return (qfileofs_t)ftello (file);
}

int Sys_FileType (const char *path)
Expand Down
6 changes: 4 additions & 2 deletions Quake/sys_sdl_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,16 @@ static HANDLE hinput, houtput;
static char cwd[1024];
static double counter_freq;

COMPILE_TIME_ASSERT (CHECK_LARGE_FILE_SUPPORT, sizeof (long long) >= sizeof (qfileofs_t));

int Sys_fseek (FILE *file, qfileofs_t ofs, int origin)
{
return _fseeki64 (file, ofs, origin);
return _fseeki64 (file, (long long)ofs, origin);
}

qfileofs_t Sys_ftell (FILE *file)
{
return _ftelli64 (file);
return (qfileofs_t)_ftelli64 (file);
}

static void Sys_GetBasedir (char *argv0, char *dst, size_t dstsize)
Expand Down

0 comments on commit 25986df

Please sign in to comment.