clean up the implementation of the new memfiles.resize

This commit is contained in:
Araq 2018-12-12 12:10:17 +01:00
commit f828e5da49

View file

@ -282,13 +282,13 @@ proc flush*(f: var MemFile; attempts: Natural = 3) =
if lastErr != EBUSY.OSErrorCode: if lastErr != EBUSY.OSErrorCode:
raiseOSError(lastErr, "error flushing mapping") raiseOSError(lastErr, "error flushing mapping")
proc resize*(f: var MemFile, newFileSize: int) = when defined(posix) or defined(nimdoc):
## resize and re-map the file underlying an ``allowRemap MemFile``. NOTE: proc resize*(f: var MemFile, newFileSize: int) {.raises: [IOError, OSError].} =
## this assumes the entire file is mapped read-write at offset zero. Also, ## resize and re-map the file underlying an ``allowRemap MemFile``.
## the value of ``.mem`` will probably change. ## **Note**: this assumes the entire file is mapped read-write at offset zero.
when defined(windows): ## Also, the value of ``.mem`` will probably change.
discard #TODO This needs to be implemented. ## **Note**: This is not (yet) avaiable on Windows.
else: when defined(posix):
if f.handle == -1: if f.handle == -1:
raise newException(IOError, raise newException(IOError,
"Cannot resize MemFile opened with allowRemap=false") "Cannot resize MemFile opened with allowRemap=false")