[commit: bytestring] ghc-7.6: Use binary mode for Char8 file functions (63f0c0c)
Paolo Capriotti
p.capriotti at gmail.com
Thu Sep 6 12:28:51 CEST 2012
Repository : ssh://darcs.haskell.org//srv/darcs/packages/bytestring
On branch : ghc-7.6
http://hackage.haskell.org/trac/ghc/changeset/63f0c0c2f37eb6fb600174ecaefae7bdf5a74f49
>---------------------------------------------------------------
commit 63f0c0c2f37eb6fb600174ecaefae7bdf5a74f49
Author: Duncan Coutts <duncan at community.haskell.org>
Date: Tue Sep 4 23:59:37 2012 +0000
Use binary mode for Char8 file functions
It doesn't actually make any difference these days, but it's better
to be explicit and consistent about it here.
>---------------------------------------------------------------
Data/ByteString/Char8.hs | 8 ++++----
Data/ByteString/Lazy/Char8.hs | 8 ++++----
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Data/ByteString/Char8.hs b/Data/ByteString/Char8.hs
index bc0589e..b3117bc 100644
--- a/Data/ByteString/Char8.hs
+++ b/Data/ByteString/Char8.hs
@@ -255,7 +255,7 @@ import Data.ByteString.Internal
import Data.Char ( isSpace )
import qualified Data.List as List (intersperse)
-import System.IO (Handle,stdout,openFile,hClose,hFileSize,IOMode(..))
+import System.IO (Handle,stdout,openBinaryFile,hClose,hFileSize,IOMode(..))
#ifndef __NHC__
import Control.Exception (bracket)
#else
@@ -1004,17 +1004,17 @@ readInteger as
-- 'pack'. It also may be more efficient than opening the file and
-- reading it using hGet.
readFile :: FilePath -> IO ByteString
-readFile f = bracket (openFile f ReadMode) hClose
+readFile f = bracket (openBinaryFile f ReadMode) hClose
(\h -> hFileSize h >>= hGet h . fromIntegral)
-- | Write a 'ByteString' to a file.
writeFile :: FilePath -> ByteString -> IO ()
-writeFile f txt = bracket (openFile f WriteMode) hClose
+writeFile f txt = bracket (openBinaryFile f WriteMode) hClose
(\h -> hPut h txt)
-- | Append a 'ByteString' to a file.
appendFile :: FilePath -> ByteString -> IO ()
-appendFile f txt = bracket (openFile f AppendMode) hClose
+appendFile f txt = bracket (openBinaryFile f AppendMode) hClose
(\h -> hPut h txt)
diff --git a/Data/ByteString/Lazy/Char8.hs b/Data/ByteString/Lazy/Char8.hs
index 9634737..840b50a 100644
--- a/Data/ByteString/Lazy/Char8.hs
+++ b/Data/ByteString/Lazy/Char8.hs
@@ -218,7 +218,7 @@ import Prelude hiding
,readFile,writeFile,appendFile,replicate,getContents,getLine,putStr,putStrLn
,zip,zipWith,unzip,notElem,repeat,iterate,interact,cycle)
-import System.IO (Handle,stdout,hClose,openFile,IOMode(..))
+import System.IO (Handle,stdout,hClose,openBinaryFile,IOMode(..))
#ifndef __NHC__
import Control.Exception (bracket)
#else
@@ -856,16 +856,16 @@ readInteger (Chunk c0 cs0) =
-- | Read an entire file /lazily/ into a 'ByteString'. Use 'text mode'
-- on Windows to interpret newlines
readFile :: FilePath -> IO ByteString
-readFile f = openFile f ReadMode >>= hGetContents
+readFile f = openBinaryFile f ReadMode >>= hGetContents
-- | Write a 'ByteString' to a file.
writeFile :: FilePath -> ByteString -> IO ()
-writeFile f txt = bracket (openFile f WriteMode) hClose
+writeFile f txt = bracket (openBinaryFile f WriteMode) hClose
(\hdl -> hPut hdl txt)
-- | Append a 'ByteString' to a file.
appendFile :: FilePath -> ByteString -> IO ()
-appendFile f txt = bracket (openFile f AppendMode) hClose
+appendFile f txt = bracket (openBinaryFile f AppendMode) hClose
(\hdl -> hPut hdl txt)
More information about the Cvs-libraries
mailing list