getFileSize and setFileSize procedures for File and AsyncFile

Platform independent procedure to set a file length. Useful when
replacing file content.
This commit is contained in:
Emery Hemingway 2017-04-04 20:26:59 -05:00
commit bc5c2d8414
No known key found for this signature in database
GPG key ID: E7AB426C639DCB96
4 changed files with 34 additions and 5 deletions

View file

@ -2895,6 +2895,9 @@ when not defined(JS): #and not defined(nimscript):
proc getFileSize*(f: File): int64 {.tags: [ReadIOEffect], benign.}
## retrieves the file size (in bytes) of `f`.
proc setFileSize*(f: File, size: int64) {.tags: [ReadIOEffect], benign.}
## changes the size of file `f` (in bytes).
proc readBytes*(f: File, a: var openArray[int8|uint8], start, len: Natural): int {.
tags: [ReadIOEffect], benign.}
## reads `len` bytes into the buffer `a` starting at ``a[start]``. Returns