on master help sign in
Make binary files the default when opening.
56c2058Niklas Larsson
CHANGELOG.md+4
@@ -1,5 +1,9 @@
1# New in next version
1# New in next version
2
2
3+
4+## Library updates
5++ `openFile` opens the file in binary mode on Windows.
6+
3## Tool updates
7## Tool updates
4+ Modules no longer require building if imports have changed but all
8+ Modules no longer require building if imports have changed but all
5 interfaces (i.e. types for names declared `export` and definitions of names
9 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
13import Prelude.Interfaces
13import Prelude.Interfaces
14import Prelude.Either
14import Prelude.Either
15import Prelude.Show
15import Prelude.Show
16+
16import IO
17import IO
17
18
18%access public export
19%access public export
@@ -108,12 +109,12 @@ validFile (FHandle h) = do x <- nullPtr h
108data Mode = Read | WriteTruncate | Append | ReadWrite | ReadWriteTruncate | ReadAppend
109data Mode = Read | WriteTruncate | Append | ReadWrite | ReadWriteTruncate | ReadAppend
109
110
110modeStr : Mode -> String
111modeStr : Mode -> String
111−modeStr Read = "r"
112+modeStr Read = "rb"
112−modeStr WriteTruncate = "w"
113+modeStr WriteTruncate = "wb"
113−modeStr Append = "a"
114+modeStr Append = "ab"
114−modeStr ReadWrite = "r+"
115+modeStr ReadWrite = "rb+"
115−modeStr ReadWriteTruncate = "w+"
116+modeStr ReadWriteTruncate = "wb+"
116−modeStr ReadAppend = "a+"
117+modeStr ReadAppend = "ab+"
117
118
118||| Open a file
119||| Open a file
119||| @ f the filename
120||| @ f the filename
src/Idris/Core/Execute.hs+1−1
@@ -345,7 +345,7 @@ execForeign env ctxt arity ty fn xs onfail
345 = case (fileStr, modeStr) of
345 = case (fileStr, modeStr) of
346 (EConstant (Str f), EConstant (Str mode)) ->
346 (EConstant (Str f), EConstant (Str mode)) ->
347 do f <- execIO $
347 do f <- execIO $
348− catch (do let m = case mode of
348+ catch (do let m = case filter (/= 'b') mode of
349 "r" -> Right ReadMode
349 "r" -> Right ReadMode
350 "w" -> Right WriteMode
350 "w" -> Right WriteMode
351 "a" -> Right AppendMode
351 "a" -> Right AppendMode