[project @ 2005-01-11 16:04:08 by simonmar]
[ghc-base.git] / GHC / Handle.hs
index 56deea6..a822696 100644 (file)
@@ -1,4 +1,4 @@
-{-# OPTIONS -fno-implicit-prelude -#include "HsBase.h" #-}
+{-# OPTIONS_GHC -fno-implicit-prelude -#include "HsBase.h" #-}
 
 #undef DEBUG_DUMP
 #undef DEBUG
@@ -819,8 +819,10 @@ openFile' filepath mode binary =
        -- (so we don't need to worry about removing the newly created file
        --  in the event of an error).
 #ifndef mingw32_TARGET_OS
-    throwErrnoIf (/=0) "openFile" 
-       (c_ftruncate (fromIntegral fd) 0)
+    if mode == WriteMode
+      then throwErrnoIf (/=0) "openFile" 
+              (c_ftruncate (fromIntegral fd) 0)
+      else return 0
 #endif
     return h