summaryrefslogtreecommitdiff
path: root/libraries/base/include
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2009-06-18 13:54:58 +0000
committerSimon Marlow <marlowsd@gmail.com>2009-06-18 13:54:58 +0000
commit2e7e5a3c1a2b44e06ee126e0b4722e2809637ef4 (patch)
treea62ce48b8f42d18f5e24ce060f0345aa5bea5df7 /libraries/base/include
parent772a1687f1a2ced725323985adc66515befc0b3e (diff)
downloadhaskell-2e7e5a3c1a2b44e06ee126e0b4722e2809637ef4.tar.gz
Windows: Unicode openFile and stat functions
Diffstat (limited to 'libraries/base/include')
-rw-r--r--libraries/base/include/HsBase.h61
1 files changed, 37 insertions, 24 deletions
diff --git a/libraries/base/include/HsBase.h b/libraries/base/include/HsBase.h
index 6ed0faa3a8..ccabc1e1f9 100644
--- a/libraries/base/include/HsBase.h
+++ b/libraries/base/include/HsBase.h
@@ -456,16 +456,6 @@ __hscore_mkdir( char *pathName, int mode )
#endif
}
-INLINE int
-__hscore_lstat( const char *fname, struct stat *st )
-{
-#if HAVE_LSTAT
- return lstat(fname, st);
-#else
- return stat(fname, st);
-#endif
-}
-
INLINE char *
__hscore_d_name( struct dirent* d )
{
@@ -491,8 +481,6 @@ __hscore_free_dirent(struct dirent *dEnt)
// and you have to ask for those explicitly. Unfortunately there
// doesn't seem to be a 64-bit version of truncate/ftruncate, so while
// hFileSize and hSeek will work with large files, hSetFileSize will not.
-#define stat(file,buf) _stati64(file,buf)
-#define fstat(fd,buf) _fstati64(fd,buf)
typedef struct _stati64 struct_stat;
typedef off64_t stsize_t;
#else
@@ -514,6 +502,37 @@ INLINE dev_t __hscore_st_dev ( struct_stat* st ) { return st->st_dev; }
INLINE ino_t __hscore_st_ino ( struct_stat* st ) { return st->st_ino; }
#endif
+#if defined(__MINGW32__)
+INLINE int __hscore_stat(wchar_t *file, struct_stat *buf) {
+ return _wstati64(file,buf);
+}
+
+INLINE int __hscore_fstat(int fd, struct_stat *buf) {
+ return _fstati64(fd,buf);
+}
+INLINE int __hscore_lstat(wchar_t *fname, struct_stat *buf )
+{
+ return _wstati64(fname,buf);
+}
+#else
+INLINE int __hscore_stat(char *file, struct_stat *buf) {
+ return stat(file,buf);
+}
+
+INLINE int __hscore_fstat(int fd, struct_stat *buf) {
+ return fstat(fd,buf);
+}
+
+INLINE int __hscore_lstat( const char *fname, struct stat *buf )
+{
+#if HAVE_LSTAT
+ return lstat(fname, buf);
+#else
+ return stat(fname, buf);
+#endif
+}
+#endif
+
#if HAVE_TERMIOS_H
INLINE tcflag_t __hscore_lflag( struct termios* ts ) { return ts->c_lflag; }
@@ -673,18 +692,20 @@ extern void __hscore_set_saved_termios(int fd, void* ts);
INLINE int __hscore_hs_fileno (FILE *f) { return fileno (f); }
-INLINE int __hscore_open(char *file, int how, mode_t mode) {
#ifdef __MINGW32__
+INLINE int __hscore_open(wchar_t *file, int how, mode_t mode) {
if ((how & O_WRONLY) || (how & O_RDWR) || (how & O_APPEND))
- return _sopen(file,how | _O_NOINHERIT,_SH_DENYRW,mode);
+ return _wsopen(file,how | _O_NOINHERIT,_SH_DENYRW,mode);
// _O_NOINHERIT: see #2650
else
- return _sopen(file,how | _O_NOINHERIT,_SH_DENYWR,mode);
+ return _wsopen(file,how | _O_NOINHERIT,_SH_DENYWR,mode);
// _O_NOINHERIT: see #2650
+}
#else
+INLINE int __hscore_open(char *file, int how, mode_t mode) {
return open(file,how,mode);
-#endif
}
+#endif
// These are wrapped because on some OSs (eg. Linux) they are
// macros which redirect to the 64-bit-off_t versions when large file
@@ -700,14 +721,6 @@ INLINE off_t __hscore_lseek(int fd, off_t off, int whence) {
}
#endif
-INLINE int __hscore_stat(char *file, struct_stat *buf) {
- return (stat(file,buf));
-}
-
-INLINE int __hscore_fstat(int fd, struct_stat *buf) {
- return (fstat(fd,buf));
-}
-
// select-related stuff
#if !defined(__MINGW32__)