Merge pull request #4670 from melted/binary_win

Make binary files the default when opening.
This commit is contained in:
Niklas Larsson 2019-03-12 11:39:48 +01:00 committed by GitHub
commit b07cac6e7e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,9 @@
# New in next version
## Library updates
+ `openFile` opens the file in binary mode on Windows.
## Tool updates
+ Modules no longer require building if imports have changed but all
interfaces (i.e. types for names declared `export` and definitions of names

View File

@ -13,6 +13,7 @@ import Prelude.Basics
import Prelude.Interfaces
import Prelude.Either
import Prelude.Show
import IO
%access public export
@ -108,12 +109,12 @@ validFile (FHandle h) = do x <- nullPtr h
data Mode = Read | WriteTruncate | Append | ReadWrite | ReadWriteTruncate | ReadAppend
modeStr : Mode -> String
modeStr Read = "r"
modeStr WriteTruncate = "w"
modeStr Append = "a"
modeStr ReadWrite = "r+"
modeStr ReadWriteTruncate = "w+"
modeStr ReadAppend = "a+"
modeStr Read = "rb"
modeStr WriteTruncate = "wb"
modeStr Append = "ab"
modeStr ReadWrite = "rb+"
modeStr ReadWriteTruncate = "wb+"
modeStr ReadAppend = "ab+"
||| Open a file
||| @ f the filename

View File

@ -345,7 +345,7 @@ execForeign env ctxt arity ty fn xs onfail
= case (fileStr, modeStr) of
(EConstant (Str f), EConstant (Str mode)) ->
do f <- execIO $
catch (do let m = case mode of
catch (do let m = case filter (/= 'b') mode of
"r" -> Right ReadMode
"w" -> Right WriteMode
"a" -> Right AppendMode