on master help sign in
Merge pull request #4670 from melted/binary_win

Make binary files the default when opening.

commitb07cac6e7e3a5a7c956dfd3c86f8d12a1b1ad8de authorNiklas Larsson <metaniklas@gmail.com> dateTue 12 Mar 2019, 11:39 (8 years ago) parent5188ef356c2058
3 files changed+12−7
CHANGELOG.md+4 libs/prelude/Prelude/File.idr+7−6 src/Idris/Core/Execute.hs+1−1
CHANGELOG.md+4
@@ -1,5 +1,9 @@
11# New in next version
22
3+
4+## Library updates
5++ `openFile` opens the file in binary mode on Windows.
6+
37## Tool updates
48+ Modules no longer require building if imports have changed but all
59 interfaces (i.e. types for names declared `export` and definitions of names
libs/prelude/Prelude/File.idr+7−6
@@ -13,6 +13,7 @@ import Prelude.Basics
1313import Prelude.Interfaces
1414import Prelude.Either
1515import Prelude.Show
16+
1617import IO
1718
1819%access public export
@@ -108,12 +109,12 @@ validFile (FHandle h) = do x <- nullPtr h
108109data Mode = Read | WriteTruncate | Append | ReadWrite | ReadWriteTruncate | ReadAppend
109110
110111modeStr : Mode -> String
111−modeStr Read = "r"
112−modeStr WriteTruncate = "w"
113−modeStr Append = "a"
114−modeStr ReadWrite = "r+"
115−modeStr ReadWriteTruncate = "w+"
116−modeStr ReadAppend = "a+"
112+modeStr Read = "rb"
113+modeStr WriteTruncate = "wb"
114+modeStr Append = "ab"
115+modeStr ReadWrite = "rb+"
116+modeStr ReadWriteTruncate = "wb+"
117+modeStr ReadAppend = "ab+"
117118
118119||| Open a file
119120||| @ f the filename
src/Idris/Core/Execute.hs+1−1
@@ -345,7 +345,7 @@ execForeign env ctxt arity ty fn xs onfail
345345 = case (fileStr, modeStr) of
346346 (EConstant (Str f), EConstant (Str mode)) ->
347347 do f <- execIO $
348− catch (do let m = case mode of
348+ catch (do let m = case filter (/= 'b') mode of
349349 "r" -> Right ReadMode
350350 "w" -> Right WriteMode
351351 "a" -> Right AppendMode