Updating accessors are also provided since the idea of this change is to
allow "updating" operations external to the module which are by their very
nature closely tied to module internals (as well as to OS interface details).
This commit is contained in:
Charles Blake
2018-12-11 10:27:27 -05:00
parent 740c5b13ea
commit 369ac2dd2d

View File

@@ -36,11 +36,26 @@ type
size*: int ## size of the memory mapped file
when defined(windows):
fHandle*: Handle
mapHandle*: Handle
wasOpened*: bool ## only close if wasOpened
fHandle: Handle
mapHandle: Handle
wasOpened: bool ## only close if wasOpened
else:
handle*: cint
handle: cint
when defined(windows):
proc fHandle*(m: MemFile): Handle = m.fHandle
proc mapHandle*(m: MemFile): Handle = m.mapHandle
proc wasOpened*(m: MemFile): bool = m.wasOpened
proc `fHandle=`*(m: var MemFile, fHandle: Handle) =
m.fHandle = fHandle
proc `mapHandle=`*(m: var MemFile, mapHandle: Handle) =
m.mapHandle = mapHandle
proc `wasOpened=`*(m: var MemFile, wasOpened: bool) =
m.wasOpened = wasOpened
else:
proc handle*(m: MemFile): cint = m.handle
proc `handle=`*(m: var MemFile, handle: cint) =
m.handle = handle
proc mapMem*(m: var MemFile, mode: FileMode = fmRead,
mappedSize = -1, offset = 0): pointer =