diff options
author | Charles Blake <cb@cblake.net> | 2018-12-11 10:27:27 -0500 |
---|---|---|
committer | Charles Blake <cb@cblake.net> | 2018-12-11 10:27:27 -0500 |
commit | 369ac2dd2db036c591983839fcf4e6129a501be8 (patch) | |
tree | 9f14c55897af4b46e65f30d0dc90628e3fa9813e /lib | |
parent | 740c5b13ead2fe02691554ef9b585d7cb4ba19fa (diff) | |
download | Nim-369ac2dd2db036c591983839fcf4e6129a501be8.tar.gz |
Address dom96/Araq opinions in https://github.com/nim-lang/Nim/pull/9922
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).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/memfiles.nim | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/pure/memfiles.nim b/lib/pure/memfiles.nim index 61eff3295..b74242370 100644 --- a/lib/pure/memfiles.nim +++ b/lib/pure/memfiles.nim @@ -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 = |