diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2015-02-18 23:09:46 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2015-02-18 23:09:46 +0100 |
commit | a8acb5ec65b5a3d6577602b9fc0d8832cf3a3287 (patch) | |
tree | e591ee144ac050ddb6cd1844d073e9fcf7d57076 | |
parent | 358d4b958c46fdc740be647ee27ecdbba15597f3 (diff) | |
parent | ecfaab68f176651e2b836423cdc5682046bbd409 (diff) | |
download | Nim-a8acb5ec65b5a3d6577602b9fc0d8832cf3a3287.tar.gz |
Merge pull request #2165 from def-/read-write-bytes
Make readBytes and writeBytes work with uint8
-rw-r--r-- | lib/system.nim | 4 | ||||
-rw-r--r-- | lib/system/sysio.nim | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/system.nim b/lib/system.nim index accc2ef25..a71699cae 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -2457,7 +2457,7 @@ when not defined(JS): #and not defined(NimrodVM): proc getFileSize*(f: File): int64 {.tags: [ReadIOEffect], benign.} ## retrieves the file size (in bytes) of `f`. - proc readBytes*(f: File, a: var openArray[int8], start, len: int): int {. + proc readBytes*(f: File, a: var openArray[int8|uint8], start, len: int): int {. tags: [ReadIOEffect], benign.} ## reads `len` bytes into the buffer `a` starting at ``a[start]``. Returns ## the actual number of bytes that have been read which may be less than @@ -2475,7 +2475,7 @@ when not defined(JS): #and not defined(NimrodVM): ## the actual number of bytes that have been read which may be less than ## `len` (if not as many bytes are remaining), but not greater. - proc writeBytes*(f: File, a: openArray[int8], start, len: int): int {. + proc writeBytes*(f: File, a: openArray[int8|uint8], start, len: int): int {. tags: [WriteIOEffect], benign.} ## writes the bytes of ``a[start..start+len-1]`` to the file `f`. Returns ## the number of actual written bytes, which may be less than `len` in case diff --git a/lib/system/sysio.nim b/lib/system/sysio.nim index aed17de80..5d68d112e 100644 --- a/lib/system/sysio.nim +++ b/lib/system/sysio.nim @@ -246,14 +246,14 @@ proc fwrite(buf: pointer, size, n: int, f: File): int {. proc readBuffer(f: File, buffer: pointer, len: int): int = result = fread(buffer, 1, len, f) -proc readBytes(f: File, a: var openArray[int8], start, len: int): int = +proc readBytes(f: File, a: var openArray[int8|uint8], start, len: int): int = result = readBuffer(f, addr(a[start]), len) proc readChars(f: File, a: var openArray[char], start, len: int): int = result = readBuffer(f, addr(a[start]), len) {.push stackTrace:off, profiler:off.} -proc writeBytes(f: File, a: openArray[int8], start, len: int): int = +proc writeBytes(f: File, a: openArray[int8|uint8], start, len: int): int = var x = cast[ptr array[0..1000_000_000, int8]](a) result = writeBuffer(f, addr(x[start]), len) proc writeChars(f: File, a: openArray[char], start, len: int): int = |