summaryrefslogtreecommitdiff
path: root/libraries/base/System/Posix/Internals.hs
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/System/Posix/Internals.hs
parent772a1687f1a2ced725323985adc66515befc0b3e (diff)
downloadhaskell-2e7e5a3c1a2b44e06ee126e0b4722e2809637ef4.tar.gz
Windows: Unicode openFile and stat functions
Diffstat (limited to 'libraries/base/System/Posix/Internals.hs')
-rw-r--r--libraries/base/System/Posix/Internals.hs26
1 files changed, 20 insertions, 6 deletions
diff --git a/libraries/base/System/Posix/Internals.hs b/libraries/base/System/Posix/Internals.hs
index 26a8a5b039..ac80574440 100644
--- a/libraries/base/System/Posix/Internals.hs
+++ b/libraries/base/System/Posix/Internals.hs
@@ -104,7 +104,7 @@ fdFileSize fd =
fileType :: FilePath -> IO IODeviceType
fileType file =
allocaBytes sizeof_stat $ \ p_stat -> do
- withCString file $ \p_file -> do
+ withFilePath file $ \p_file -> do
throwErrnoIfMinus1Retry "fileType" $
c_stat p_file p_stat
statGetType p_stat
@@ -172,6 +172,14 @@ fdGetMode fd = do
return mode
+#ifdef mingw32_HOST_OS
+withFilePath :: FilePath -> (CWString -> IO a) -> IO a
+withFilePath = withCWString
+#else
+withFilePath :: FilePath -> (CString -> IO a) -> IO a
+withFilePath = withCString
+#endif
+
-- ---------------------------------------------------------------------------
-- Terminal-related stuff
@@ -338,6 +346,12 @@ setCloseOnExec fd = do
-- -----------------------------------------------------------------------------
-- foreign imports
+#if !defined(mingw32_HOST_OS) && !defined(__MINGW32__)
+type CFilePath = CString
+#else
+type CFilePath = CWString
+#endif
+
foreign import ccall unsafe "HsBase.h access"
c_access :: CString -> CInt -> IO CInt
@@ -374,10 +388,10 @@ foreign import ccall unsafe "HsBase.h __hscore_lseek"
#endif
foreign import ccall unsafe "HsBase.h __hscore_lstat"
- lstat :: CString -> Ptr CStat -> IO CInt
+ lstat :: CFilePath -> Ptr CStat -> IO CInt
-foreign import ccall unsafe "HsBase.h __hscore_open"
- c_open :: CString -> CInt -> CMode -> IO CInt
+foreign import ccall unsafe "__hscore_open"
+ c_open :: CFilePath -> CInt -> CMode -> IO CInt
foreign import ccall unsafe "HsBase.h opendir"
c_opendir :: CString -> IO (Ptr CDir)
@@ -391,8 +405,8 @@ foreign import ccall unsafe "HsBase.h read"
foreign import ccall unsafe "HsBase.h rewinddir"
c_rewinddir :: Ptr CDir -> IO ()
-foreign import ccall unsafe "HsBase.h __hscore_stat"
- c_stat :: CString -> Ptr CStat -> IO CInt
+foreign import ccall unsafe "__hscore_stat"
+ c_stat :: CFilePath -> Ptr CStat -> IO CInt
foreign import ccall unsafe "HsBase.h umask"
c_umask :: CMode -> IO CMode