From 807784db826f4718c800e0554c834fbbddfecce7 Mon Sep 17 00:00:00 2001 From: Anatoly Galiulin Date: Wed, 13 Apr 2016 16:44:17 +0600 Subject: Add ``readFile`` implementation for nimvm --- lib/system.nim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib') diff --git a/lib/system.nim b/lib/system.nim index 53204306d..231866e90 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2624,6 +2624,14 @@ when not defined(JS): #and not defined(nimscript): else: result = 0 when defined(nimscript): + proc readFile*(filename: string): string {.tags: [ReadIOEffect], benign.} + ## Opens a file named `filename` for reading. + ## + ## Then calls `readAll <#readAll>`_ and closes the file afterwards. + ## Returns the string. Raises an IO exception in case of an error. If + ## you need to call this inside a compile time macro you can use + ## `staticRead <#staticRead>`_. + proc writeFile*(filename, content: string) {.tags: [WriteIOEffect], benign.} ## Opens a file named `filename` for writing. Then writes the ## `content` completely to the file and closes the file afterwards. -- cgit 1.4.1-2-gfad0