diff --git a/compiler/vmops.nim b/compiler/vmops.nim index f7eafcd609..0d6d753734 100644 --- a/compiler/vmops.nim +++ b/compiler/vmops.nim @@ -143,7 +143,7 @@ proc registerAdditionalOps*(c: PCtx) = wrap1s(fileExists, osop) wrapDangerous(writeFile, ioop) wrap1s(readFile, ioop) - wrap2si(staticReadLines, ioop) + wrap2si(readLines, ioop) systemop getCurrentExceptionMsg systemop getCurrentException registerCallback c, "stdlib.*.staticWalkDir", proc (a: VmArgs) {.nimcall.} = diff --git a/lib/system/io.nim b/lib/system/io.nim index 9310b02e3f..a326de8618 100644 --- a/lib/system/io.nim +++ b/lib/system/io.nim @@ -686,10 +686,10 @@ proc writeFile*(filename, content: string) {.tags: [WriteIOEffect], benign.} = sysFatal(IOError, "cannot open: " & filename) -proc staticReadLines*(filename: string, n: Natural): seq[TaintedString] = - ## Compile time read `n` lines from the file named `filename`. Raises an IO exception +proc readLines*(filename: string, n: Natural): seq[TaintedString] = + ## read `n` lines from the file named `filename`. Raises an IO exception ## in case of an error. Raises EOF if file does not contain at least `n` lines. - ## A line of text may be delimited by ``LF`` or ``CRLF``. + ## Available at compile time. A line of text may be delimited by ``LF`` or ``CRLF``. ## The newline character(s) are not part of the returned strings. var f: File if open(f, filename): @@ -703,6 +703,8 @@ proc staticReadLines*(filename: string, n: Natural): seq[TaintedString] = else: sysFatal(IOError, "cannot open: " & filename) +proc readLines*(filename: string): seq[TaintedString] {.deprecated: "use readLines with two arguments".} = + readLines(filename, 1) iterator lines*(filename: string): TaintedString {.tags: [ReadIOEffect].} = ## Iterates over any line in the file named `filename`. diff --git a/tests/vm/tfile_rw.nim b/tests/vm/tfile_rw.nim index 75242794c0..8d7a2ca95d 100644 --- a/tests/vm/tfile_rw.nim +++ b/tests/vm/tfile_rw.nim @@ -13,7 +13,7 @@ static: writeFile(filename, mytext) const myfile_str = staticRead(filename) const myfile_str2 = readFile(filename) -const myfile_str_seq = staticReadLines(filename, 3) +const myfile_str_seq = readLines(filename, 3) static: doAssert myfile_str == mytext