From: sof Date: Mon, 26 Nov 2001 16:37:33 +0000 (+0000) Subject: [project @ 2001-11-26 16:37:33 by sof] X-Git-Tag: Approximately_9120_patches~519 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=5680ea4b2035198981739e24ad04cd0e0d133172;p=ghc-hetmet.git [project @ 2001-11-26 16:37:33 by sof] fdType: clarify that this op will fail with non-file handles/descriptors under Win32. --- diff --git a/ghc/lib/std/PrelPosix.hsc b/ghc/lib/std/PrelPosix.hsc index c6b09f5..5d85f61 100644 --- a/ghc/lib/std/PrelPosix.hsc +++ b/ghc/lib/std/PrelPosix.hsc @@ -1,7 +1,6 @@ {-# OPTIONS -fno-implicit-prelude #-} -- --------------------------------------------------------------------------- --- $Id: PrelPosix.hsc,v 1.14 2001/09/26 10:35:41 simonmar Exp $ -- -- POSIX support layer for the standard libraries -- @@ -78,17 +77,19 @@ fdFileSize fd = data FDType = Directory | Stream | RegularFile deriving (Eq) +-- NOTE: On Win32 platforms, this will only work with file descriptors +-- referring to file handles. i.e., it'll fail for socket FDs. fdType :: Int -> IO FDType fdType fd = allocaBytes (#const sizeof(struct stat)) $ \ p_stat -> do - throwErrnoIfMinus1Retry "fileSize" $ + throwErrnoIfMinus1Retry "fdType" $ c_fstat (fromIntegral fd) p_stat c_mode <- (#peek struct stat, st_mode) p_stat :: IO CMode case () of _ | s_isdir c_mode -> return Directory | s_isfifo c_mode || s_issock c_mode -> return Stream - | s_isreg c_mode -> return RegularFile - | otherwise -> ioException ioe_unknownfiletype + | s_isreg c_mode -> return RegularFile + | otherwise -> ioException ioe_unknownfiletype ioe_unknownfiletype = IOError Nothing UnsupportedOperation "fdType" "unknown file type" Nothing