diff --git a/build/wince/shunt/include/mozce_defs.h b/build/wince/shunt/include/mozce_defs.h index 7aa013d8f2c2..cfdf34eb6c23 100755 --- a/build/wince/shunt/include/mozce_defs.h +++ b/build/wince/shunt/include/mozce_defs.h @@ -177,7 +177,9 @@ typedef INT_PTR intptr_t; #define _S_IFREG 0100000 /* stat, is a normal file */ #define _S_IREAD 0000400 /* stat, can read */ #define _S_IWRITE 0000200 /* stat, can write */ -#define _S_IEXEC 0000100 +#define _S_IEXEC 0000100 + +#define S_IFREG 0x8000 struct stat { @@ -306,18 +308,18 @@ typedef struct MAT2 { struct color{ - unsigned char Red; - unsigned char Green; - unsigned char Blue; - double Alpha; + unsigned char Red; + unsigned char Green; + unsigned char Blue; + double Alpha; }; #ifndef SEE_MASK_FLAG_DDEWAIT -#define SEE_MASK_FLAG_DDEWAIT 0 +#define SEE_MASK_FLAG_DDEWAIT 0 #endif #ifndef SEE_MASK_INVOKEIDLIST -#define SEE_MASK_INVOKEIDLIST 0 +#define SEE_MASK_INVOKEIDLIST 0 #endif diff --git a/build/wince/shunt/include/mozce_shunt.h b/build/wince/shunt/include/mozce_shunt.h index 28fdfaf5688e..f91d24a52ef9 100755 --- a/build/wince/shunt/include/mozce_shunt.h +++ b/build/wince/shunt/include/mozce_shunt.h @@ -61,7 +61,6 @@ #define _isatty isatty #undef fileno #define fileno (int)_fileno -#define fstat (int)_fstat #define _mbctolower tolower #define _mbsicmp mbsicmp #define _mbsdec mbsdec @@ -217,6 +216,7 @@ extern "C" { MOZCE_SHUNT_API int unlink(const char *pathname); MOZCE_SHUNT_API int lseek(int fildes, int offset, int whence); + MOZCE_SHUNT_API int fstat(FILE* handle, struct stat* buff); // From stdlib.cpp MOZCE_SHUNT_API void splitpath(const char* inPath, char* outDrive, char* outDir, char* outFname, char* outExt); diff --git a/build/wince/shunt/stat.cpp b/build/wince/shunt/stat.cpp index 423e4b896074..6dff2dd3da59 100755 --- a/build/wince/shunt/stat.cpp +++ b/build/wince/shunt/stat.cpp @@ -47,6 +47,32 @@ extern "C" { } #endif +MOZCE_SHUNT_API int fstat(FILE* handle, struct stat* buff) +{ + WINCE_LOG_API_CALL("fstat called\n"); + + int position = ftell(handle); + if (position < 0) + return -1; + + if (fseek(handle, 0, SEEK_END) < 0) + return -1; + + buff->st_size = ftell(handle); + + if (fseek(handle, position, SEEK_SET) < 0) + return -1; + + if (buff->st_size < 0) + return -1; + + buff->st_mode = _S_IFREG | _S_IREAD | _S_IWRITE | _S_IEXEC; + /* can't get time from a file handle on wince */ + buff->st_ctime = 0; + buff->st_atime = 0; + buff->st_mtime = 0; + return 0; +} MOZCE_SHUNT_API int stat(const char* inPath, struct stat* outStats) { @@ -71,7 +97,6 @@ MOZCE_SHUNT_API int stat(const char* inPath, struct stat* outStats) if (readHandle != INVALID_HANDLE_VALUE && readHandle != NULL) { - retval = 0; outStats->st_size = findData.nFileSizeLow;