summary refs log tree commit diff stats
path: root/lib/impure/re.nim
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-06-16 10:47:44 +0200
committerAraq <rumpf_a@web.de>2011-06-16 10:47:44 +0200
commit04f9c2585ae53555cdbec4031b0d9af270b8dc86 (patch)
tree5432c3fb2b25a70b1e74aed01731be6f74b2ed66 /lib/impure/re.nim
parentde659eba65b5ad098a403449c4b2b1067d04a2cf (diff)
downloadNim-04f9c2585ae53555cdbec4031b0d9af270b8dc86.tar.gz
readFile raises EIO instead of returning nil; added system.writeFile
Diffstat (limited to 'lib/impure/re.nim')
-rwxr-xr-xlib/impure/re.nim12
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/impure/re.nim b/lib/impure/re.nim
index ccc13248a..eaa712f01 100755
--- a/lib/impure/re.nim
+++ b/lib/impure/re.nim
@@ -342,18 +342,10 @@ proc parallelReplace*(s: string, subs: openArray[
 proc transformFile*(infile, outfile: string,
                     subs: openArray[tuple[pattern: TRegEx, repl: string]]) =
   ## reads in the file `infile`, performs a parallel replacement (calls
-  ## `parallelReplace`) and writes back to `outfile`. Calls ``quit`` if an
+  ## `parallelReplace`) and writes back to `outfile`. Raises ``EIO`` if an
   ## error occurs. This is supposed to be used for quick scripting.
   var x = readFile(infile)
-  if not isNil(x):
-    var f: TFile
-    if open(f, outfile, fmWrite):
-      write(f, x.parallelReplace(subs))
-      close(f)
-    else:
-      quit("cannot open for writing: " & outfile)
-  else:
-    quit("cannot open for reading: " & infile)
+  writeFile(outfile, x.parallelReplace(subs))
   
 iterator split*(s: string, sep: TRegEx): string =
   ## Splits the string `s` into substrings.