diff options
author | Araq <rumpf_a@web.de> | 2012-03-04 21:44:56 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-03-04 21:44:56 +0100 |
commit | ff4a69b6243f8f14cea78d428d2fd78ee4be3823 (patch) | |
tree | 2713edb2c4805551b08c6e516d514a383604fae2 /lib/system/sysio.nim | |
parent | 34d3c042af7f70ce579c5ea76c8ca22298da368c (diff) | |
download | Nim-ff4a69b6243f8f14cea78d428d2fd78ee4be3823.tar.gz |
win64 is a supported target; bugfix: nimrod c -r on windows; stdlib uses wide char versions of the WinAPI
Diffstat (limited to 'lib/system/sysio.nim')
-rwxr-xr-x | lib/system/sysio.nim | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index 33d7dc5f2..0180bcdae 100755 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -34,9 +34,6 @@ proc ftell(f: TFile): int {.importc: "ftell", noDecl.} proc setvbuf(stream: TFile, buf: pointer, typ, size: cint): cint {. importc, nodecl.} -proc freopen(path, mode: cstring, stream: TFile): TFile {.importc: "freopen", - nodecl.} - proc write(f: TFile, c: cstring) = fputs(c, f) var @@ -161,7 +158,33 @@ proc rawEcho(x: string) {.inline, compilerproc.} = write(stdout, x) proc rawEchoNL() {.inline, compilerproc.} = write(stdout, "\n") # interface to the C procs: -proc fopen(filename, mode: CString): pointer {.importc: "fopen", noDecl.} + +when defined(windows) and not defined(useWinAnsi): + include "system/widestrs" + + proc wfopen(filename, mode: widecstring): pointer {. + importc: "_wfopen", nodecl.} + proc wfreopen(filename, mode: widecstring, stream: TFile): TFile {. + importc: "_wfreopen", nodecl.} + + proc fopen(filename, mode: CString): pointer = + var f = allocWideCString(filename) + var m = allocWideCString(mode) + result = wfopen(f, m) + dealloc m + dealloc f + + proc freopen(filename, mode: cstring, stream: TFile): TFile = + var f = allocWideCString(filename) + var m = allocWideCString(mode) + result = wfreopen(f, m, stream) + dealloc m + dealloc f + +else: + proc fopen(filename, mode: CString): pointer {.importc: "fopen", noDecl.} + proc freopen(filename, mode: cstring, stream: TFile): TFile {. + importc: "freopen", nodecl.} const FormatOpen: array [TFileMode, string] = ["rb", "wb", "w+b", "r+b", "ab"] |