diff options
author | Araq <rumpf_a@web.de> | 2011-06-16 10:47:44 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-06-16 10:47:44 +0200 |
commit | 04f9c2585ae53555cdbec4031b0d9af270b8dc86 (patch) | |
tree | 5432c3fb2b25a70b1e74aed01731be6f74b2ed66 /lib/pure/pegs.nim | |
parent | de659eba65b5ad098a403449c4b2b1067d04a2cf (diff) | |
download | Nim-04f9c2585ae53555cdbec4031b0d9af270b8dc86.tar.gz |
readFile raises EIO instead of returning nil; added system.writeFile
Diffstat (limited to 'lib/pure/pegs.nim')
-rwxr-xr-x | lib/pure/pegs.nim | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/lib/pure/pegs.nim b/lib/pure/pegs.nim index 988e510e3..b7469f65b 100755 --- a/lib/pure/pegs.nim +++ b/lib/pure/pegs.nim @@ -947,18 +947,10 @@ proc transformFile*(infile, outfile: string, subs: openArray[tuple[pattern: TPeg, repl: string]]) {. rtl, extern: "npegs$1".} = ## 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: TPeg): string = ## Splits the string `s` into substrings. |