summary refs log tree commit diff stats
path: root/lib/system/sysio.nim
diff options
context:
space:
mode:
authorAndreas Rumpf <andreas@andreas-desktop>2010-01-29 01:50:39 +0100
committerAndreas Rumpf <andreas@andreas-desktop>2010-01-29 01:50:39 +0100
commitecb5a8db9997dd9b986e7b5649af5b45561f871b (patch)
treea48a6a770b7319b9d9508299031c9f799e976e2e /lib/system/sysio.nim
parent5eea125ba73a5768a264c5d4fc8cc55fba8d5fe8 (diff)
downloadNim-ecb5a8db9997dd9b986e7b5649af5b45561f871b.tar.gz
bugfixes for the high-level postgreSQL wrapper
Diffstat (limited to 'lib/system/sysio.nim')
-rwxr-xr-xlib/system/sysio.nim5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim
index 8b6d0e285..3c99a5eed 100755
--- a/lib/system/sysio.nim
+++ b/lib/system/sysio.nim
@@ -51,7 +51,6 @@ proc readLine(f: TFile): string =
   result = ""
   rawReadLine(f, result)
 
-proc write(f: TFile, s: string) = fputs(s, f)
 proc write(f: TFile, i: int) = 
   when sizeof(int) == 8:
     fprintf(f, "%lld", i)
@@ -167,6 +166,10 @@ proc writeChars(f: TFile, a: openarray[char], start, len: int): int =
 proc writeBuffer(f: TFile, buffer: pointer, len: int): int =
   result = fwrite(buffer, 1, len, f)
 
+proc write(f: TFile, s: string) =
+  if writeBuffer(f, cstring(s), s.len) != s.len:
+    raise newException(EIO, "cannot write string to file")
+
 proc setFilePos(f: TFile, pos: int64) =
   if fseek(f, clong(pos), 0) != 0:
     raise newException(EIO, "cannot set file position")