Commit 7549e3e5 authored by rswindell's avatar rswindell
Browse files

Added wrappers for Microsoft functions: _chsize_s and _filelengthi64

parent 9d444cf2
......@@ -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 2004 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 *
......@@ -56,6 +56,7 @@
/****************************************************************************/
/* Returns the modification time of the file in 'fd' */
/* or -1 if file doesn't exist. */
/****************************************************************************/
time_t DLLCALL filetime(int fd)
{
......@@ -71,6 +72,7 @@ time_t DLLCALL filetime(int fd)
/****************************************************************************/
/* Returns the length of the file in 'fd' */
/* or -1 if file doesn't exist. */
/****************************************************************************/
long DLLCALL filelength(int fd)
{
......@@ -82,6 +84,21 @@ long DLLCALL filelength(int fd)
return(st.st_size);
}
/****************************************************************************/
/* Returns the length (63-bits) of the file in 'fd' */
/* or -1 if file doesn't exist. */
/* Microsoftism */
/****************************************************************************/
int64_t DLLCALL _filelengthi64(int fd)
{
struct stat st;
if(fstat(fd, &st)!=0)
return(-1);
return(st.st_size);
}
/* Sets a lock on a portion of a file */
int DLLCALL lock(int fd, long pos, long len)
{
......
......@@ -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 *
......@@ -115,6 +115,7 @@
#endif
#define chsize(fd,size) ftruncate(fd,size)
#define _chsize_s(fd,size) ftruncate(fd,size) /* supports 64-bit size */
#define tell(fd) lseek(fd,0,SEEK_CUR)
#define eof(fd) (tell(fd)==filelength(fd))
......@@ -153,8 +154,9 @@ extern "C" {
#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 long DLLCALL filelength(int fd);
DLLEXPORT int64_t DLLCALL _filelengthi64(int fd);
#endif
#if defined(__unix__)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment