--- sbbs/src/xpdev/filewrap.h 2018/04/24 16:41:24 1.1 +++ sbbs/src/xpdev/filewrap.h 2018/04/24 16:45:30 1.1.1.2 @@ -2,13 +2,13 @@ /* File system-call wrappers */ -/* $Id: filewrap.h,v 1.1 2018/04/24 16:41:24 root Exp $ */ +/* $Id: filewrap.h,v 1.1.1.2 2018/04/24 16:45:30 root Exp $ */ /**************************************************************************** * @format.tab-size 4 (Plain Text/Source Code File Header) * * @format.use-tabs true (see http://www.synchro.net/ptsc_hdr.html) * * * - * Copyright 2005 Rob Swindell - http://www.synchro.net/copyright.html * + * Copyright 2011 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 * @@ -39,6 +39,7 @@ #define _FILEWRAP_H #include "wrapdll.h" /* DLLEXPORT and DLLCALL */ +#include "gen_defs.h" /* int32_t, int64_t */ #include /* S_IREAD and S_IWRITE (for use with sopen) */ #include @@ -73,6 +74,19 @@ #define SH_COMPAT 0 #endif + #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS==64) + #define lseek _lseeki64 + #define tell _telli64 + #define filelength _filelengthi64 + #define stat _stati64 + #define fstat _fstati64 + #define fseeko _fseeki64 + #define ftello _ftelli64 + #else + #define fseeko fseek + #define ftello ftell + #endif + #elif defined(__unix__) #ifdef __solaris__ @@ -109,6 +123,11 @@ #define SH_COMPAT 0 #endif #endif + + #ifndef DEFFILEMODE + #define DELFILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH) + #endif + #define chsize(fd,size) ftruncate(fd,size) #define tell(fd) lseek(fd,0,SEEK_CUR) #define eof(fd) (tell(fd)==filelength(fd)) @@ -119,6 +138,10 @@ #endif +#ifndef DEFFILEMODE +#define DEFFILEMODE (S_IREAD|S_IWRITE) +#endif + /* Standard file descriptors. */ #ifndef STDIN_FILENO #define STDIN_FILENO 0 /* Standard input */ @@ -139,19 +162,24 @@ extern "C" { #endif #if !defined(__BORLANDC__) && !defined(__WATCOMC__) - DLLEXPORT int DLLCALL lock(int fd, long pos, long len); - DLLEXPORT int DLLCALL unlock(int fd, long pos, long len); + DLLEXPORT int DLLCALL lock(int fd, off_t pos, off_t len); + DLLEXPORT int DLLCALL unlock(int fd, off_t pos, off_t len); #endif #if !defined(__BORLANDC__) && defined(__unix__) - DLLEXPORT int DLLCALL sopen(const char* fn, int sh_access, int share, ...); - DLLEXPORT long DLLCALL filelength(int fd); + DLLEXPORT int DLLCALL sopen(const char* fn, int sh_access, int share, ...); + DLLEXPORT off_t DLLCALL filelength(int fd); #endif #if defined(__unix__) DLLEXPORT FILE * DLLCALL _fsopen(char *pszFilename, char *pszMode, int shmode); #endif +#if defined(_MSC_VER) && (_MSC_VER < 1300) /* missing prototypes */ + DLLEXPORT int DLLCALL _fseeki64(FILE*, int64_t, int origin); + DLLEXPORT int64_t DLLCALL _ftelli64(FILE*); +#endif + DLLEXPORT time_t DLLCALL filetime(int fd); #if defined(__cplusplus)