diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c index 09060e1fb1dbfa1c6b25e3941ff325679ab10238..8382624ffb26de86d3200b3888c2f639b1481d5f 100644 --- a/src/xpdev/dirwrap.c +++ b/src/xpdev/dirwrap.c @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -388,8 +388,9 @@ int DLLCALL setfdate(const char* filename, time_t t) /****************************************************************************/ /* Returns the length of the file in 'filename' */ +/* or -1 if the file doesn't exist */ /****************************************************************************/ -long DLLCALL flength(const char *filename) +int64_t DLLCALL flength(const char *filename) { #if defined(__BORLANDC__) && !defined(__unix__) /* stat() doesn't work right */ @@ -397,7 +398,7 @@ long DLLCALL flength(const char *filename) struct _finddata_t f; if(access((char*)filename,0)==-1) - return(-1L); + return(-1); if((handle=_findfirst((char*)filename,&f))==-1) return(-1); @@ -408,13 +409,21 @@ long DLLCALL flength(const char *filename) #else +#ifdef _WIN32 + struct _stati64 st; +#else struct stat st; +#endif if(access(filename,0)==-1) - return(-1L); + return(-1); +#ifdef _WIN32 + if(_stati64(filename, &st)!=0) +#else if(stat(filename, &st)!=0) - return(-1L); +#endif + return(-1); return(st.st_size); diff --git a/src/xpdev/dirwrap.h b/src/xpdev/dirwrap.h index 69a9bffe3a281e530cf81a7c8aaf72b351c2e938..c1a4f054709ab463dcc176bbfcc4bae104ed57f2 100644 --- a/src/xpdev/dirwrap.h +++ b/src/xpdev/dirwrap.h @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2009 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -218,7 +218,7 @@ extern "C" { /* General file system wrappers for all platforms and compilers */ DLLEXPORT BOOL DLLCALL fexist(const char *filespec); DLLEXPORT BOOL DLLCALL fexistcase(char *filespec); /* fixes upr/lwr case fname */ -DLLEXPORT long DLLCALL flength(const char *filename); +DLLEXPORT int64_t DLLCALL flength(const char *filename); DLLEXPORT time_t DLLCALL fdate(const char *filename); DLLEXPORT int DLLCALL setfdate(const char* filename, time_t t); DLLEXPORT BOOL DLLCALL isdir(const char *filename); diff --git a/src/xpdev/gen_defs.h b/src/xpdev/gen_defs.h index ccde73003e4c3051c0b9c6bee05ac2ac9c9aa38e..f0978573d5d783498ed690a9e062e0a7bf922e11 100644 --- a/src/xpdev/gen_defs.h +++ b/src/xpdev/gen_defs.h @@ -8,7 +8,7 @@ * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2007 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2010 Rob Swindell - http://www.synchro.net/copyright.html * * * * This library is free software; you can redistribute it and/or * * modify it under the terms of the GNU Lesser General Public License * @@ -153,6 +153,14 @@ typedef uchar uint8_t; typedef ushort uint16_t; typedef ulong uint32_t; +#if defined(_MSC_VER) || defined(__WATCOMC__) +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#else +typedef signed long long int int64_t; +typedef unsigned long long int uint64_t; +#endif + #endif /* Legacy 32-bit time_t */