[project @ 2005-10-13 11:09:50 by ross]
[haskell-directory.git] / System / Posix / Internals.hs
index 7e3ba58..a1ee00b 100644 (file)
@@ -8,7 +8,7 @@
 -- 
 -- Maintainer  :  cvs-ghc@haskell.org
 -- Stability   :  internal
--- Portability :  non-portable
+-- Portability :  non-portable (requires POSIX)
 --
 -- POSIX support layer for the standard libraries.
 -- This library is built on *every* platform, including Win32.
@@ -85,7 +85,7 @@ fdFileSize fd =
     c_size <- st_size p_stat :: IO COff
     return (fromIntegral c_size)
 
-data FDType  = Directory | Stream | RegularFile
+data FDType  = Directory | Stream | RegularFile | RawDevice
               deriving (Eq)
 
 fileType :: FilePath -> IO FDType
@@ -112,13 +112,15 @@ statGetType p_stat = do
         | s_isfifo c_mode || s_issock c_mode || s_ischr  c_mode
                                -> return Stream
        | s_isreg c_mode        -> return RegularFile
+        -- Q: map char devices to RawDevice too?
+       | s_isblk c_mode        -> return RawDevice
        | otherwise             -> ioError ioe_unknownfiletype
     
 
 ioe_unknownfiletype = IOError Nothing UnsupportedOperation "fdType"
                        "unknown file type" Nothing
 
-#if defined(mingw32_HOST_OS) || defined(__MINGW32__)
+#if __GLASGOW_HASKELL__ && (defined(mingw32_HOST_OS) || defined(__MINGW32__))
 closeFd :: Bool -> CInt -> IO CInt
 closeFd isStream fd 
   | isStream  = c_closesocket fd