Commit graph

55 commits

Author SHA1 Message Date
Dmitry Atamanov
bf5d619a52 Add MemMapFileStream. Fixes in memFiles. (#7944)
* Add MemMapFileStream

* Added tests

* Fixed bug in memfiles (zero index for string)

* Added flush to changelog

* Attempt to fix Win's nuances

* Fix attempt to fix

* Continue...

* And again...

* Reworked tests (all for win on Win)

* Fixes in flush (Win)

* Replace fn vars to consts

* Added the attempts parameter to the flush

* Replace while to for

* Move to memfiles

* Use Natural instead of uint

* Better error messages for append mode. Handle specific cases.
2018-06-14 17:34:26 +01:00
Araq
bbb0fd4eb7 remove deprecated stuff from the stdlib; introduce better deprecation warnings 2018-05-05 21:45:07 +02:00
Araq
e593fef320 memfiles: better error checking for Windows; refs #6361 2018-01-03 13:24:20 +01:00
Denis Rumyantsev
71b1377be9 Update memfiles.nim (#6328)
FIX error in MemFile fileSize
2017-09-15 12:50:10 +02:00
Arne Döring
000b8afd26 Remove expr/stmt (#5857) 2017-07-25 09:28:23 +02:00
c-blake
d59441340d Fixes incorrect fd==0 test on Unix; Conserves handles by default. (#5512)
* Fix 2 problems.  First, 0 is a valid fd on Unix (easily gotten if user first
closes all fds and then starts using memfiles).  Use -1 instead for an invalid
fd.  Second, it is best practice to conserve open fds on Unix and file handles
on Windows.  These handles are not needed unless the user wants to remap the
memory with ``mapMem`` (or a hypothetical future ``proc resize``).  Adding a
new bool param ``allowRemap=false`` to ``memfiles.open`` solves this cleanly
in a "mostly" backward compatible way.  This is only "mostly" because the
default ``false`` case does not keep unneeded resources allocated, but that
most sensible default means that any ``mapMem`` callers need to fix all their
open calls to have allowRemap=true, as this PR also does for tmemfiles2.nim.
* Include backwards compatibility note.
2017-03-12 20:45:10 +01:00
Charles Blake
ec1a77bb86 Oops - forgot export marker. 2016-12-22 16:12:31 -05:00
Charles Blake
1bb6775f92 Add a proc == for MemSlice. 2016-12-22 15:25:13 -05:00
James Parkinson
a241b0f131 Add doco on mapMem(), extend doco on open(), and add extra lines space for readability 2016-08-05 20:55:25 +10:00
Jacek Sieka
64b0485207 fix types of ansi_c/sysio to more closely match C ABI
also fixes some instances of using C library functions when there are
nim alternatives available
2016-06-05 12:03:20 +08:00
JamesP
305766a9fa Bug fix: change non-fmRead file mode to set GENERIC_READ or GENERIC_WRITE
instead of GENERIC_ALL
which on 64bit windows rasied an [OSError] exception
2015-09-24 09:04:55 +10:00
JamesP
bdc1c5ee84 change type of windows handles to Handle 2015-09-24 09:03:03 +10:00
JamesP
7656fae456 fix wasOpened reference and set to false on close 2015-09-23 06:20:19 +10:00
JamesP
d23c697044 Add wasOpened flag for windows, so not attempt close when unopened 2015-09-22 16:16:51 +10:00
JamesP
b6b2750327 Undo zero check 2015-09-22 15:54:44 +10:00
JamesP
88fc415c69 bug fix: close() only unmapViewOfFile() when fHandle is valid.
Added extra test on windows close so if already closed it
doesn't throw an exception.
2015-09-12 14:41:50 +10:00
Adam Strzelecki
43bddf62dd lib: Trim .nim files trailing whitespace
via OSX: find . -name '*.nim' -exec sed -i '' -E 's/[[:space:]]+$//' {} +
2015-09-04 23:03:56 +02:00
Charles Blake
5ec4b7946f Add note about what is included. 2015-08-04 13:25:41 -04:00
Charles Blake
0487ad4180 Use hyperlinks to refer to other procs. 2015-08-04 13:16:27 -04:00
Charles Blake
abf15ec6ce Expand memSlices doc comment & use better example.
Have lines() iterators docs point back to memSlices() for details.
2015-08-04 12:11:33 -04:00
Charles Blake
9e8b4475e2 Spruce up doc comments as per dom96 suggestions. 2015-08-03 12:34:03 -04:00
Charles Blake
c373c7209a toString --> $. 2015-08-03 12:26:08 -04:00
Charles Blake
1bea224c4a Try to get examples to render right as HTML. 2015-08-02 12:29:24 -04:00
Charles Blake
2e4e0ffd3d Add some example code blocks. 2015-08-02 12:25:57 -04:00
Charles Blake
ad67bfcf46 Quote the \ in doc comments. 2015-08-02 12:21:49 -04:00
Charles Blake
63c4f204e8 Add some little one-line doc comment of MemSlice. 2015-08-02 12:20:05 -04:00
Charles Blake
2bcd4e9a38 Add top of module comment. Re-order definitions to
type, then converter, then 3 iterators lowest- to highest-level
(also fastest to slowest) including a new intermediate iterator
lines(MemFile, buffer) that is more like readLine(File) in case
that helps anyone port code.
Add doc comments.
Also have toString just use newString+c_memcpy instead of
currently fragile toNimStr which Araq wants a separate PR for.
2015-08-02 12:03:52 -04:00
Charles Blake
fc54fbfb98 Nix unchecked which has no semantics for objects. 2015-08-02 05:28:21 -04:00
Charles Blake
0b4c816cba cstring->pointer in MemSlice to make consistent with MemFile and
also to make more clear the care required to use MemSlice instances.
(E.g., memXXX functions rather than strXXX functions).
2015-07-29 06:14:44 -04:00
Charles Blake
f2c5676767 Remove NUL termination unneeded post toNimStr fix. 2015-07-28 06:45:07 -04:00
Charles Blake
ae303cc1c3 Rename [rR]ecord->[mM]emSlice, rec->ms, End->ending. Also update some comments. 2015-07-26 07:52:30 -04:00
Charles Blake
3f4255dd14 Beg->data, Len->size to address Varriount's issue. I was unaware of
lower case members as a strict style convention.
2015-07-24 17:23:11 -04:00
Charles Blake
a12c9cfb9d Add MemFile text interface factored so users can optionally skip Nim string
construction (e.g. to filter many lines out before building strings).  Only
Windows and/or Unix line endings are supported by default, though fiddling
with delim/eat arguments can probably support archaic MacOS9 files.
2015-07-24 14:38:20 -04:00
pdw
6914244f30 lib/pure/e-o - Dropped 'T' from types 2015-06-04 13:18:35 +02:00
Guillaume Gelin
3119fe087d Happy new year! 2015-01-06 15:26:33 +01:00
Araq
d05df2173b Nimrod renamed to Nim 2014-08-28 09:50:51 +02:00
Araq
df172806ea big rename 2014-08-28 00:24:52 +02:00
Araq
11b6958755 big rename 2014-08-27 23:42:51 +02:00
Araq
2f43fdb837 renamefest 2014-08-23 01:43:49 +02:00
Nick Greenfield
3a57052e57 Revert "Do not automatically use MAP_POPULATE for opening mmap files."
This reverts commit cba75db4e3. The prior
commit yields a compiler error 'error: lvalue required as left operand
of assignment; MAP_POPULATE = ((int) 0);'. So for now this branch
*always* adds MAP_POPULATE when using the open and mapMem procs.
2014-07-23 11:36:35 -07:00
Nick Greenfield
cba75db4e3 Do not automatically use MAP_POPULATE for opening mmap files.
Adds use_map_populate keyword to memfiles.open and memfiles.mapMem
to govern MAP_POPULATE use. This is set to false by default.
2014-07-23 11:31:03 -07:00
Nick Greenfield
272fd42c97 Add automatic MAP_POPULATE flag for opening read_only (MAP_PRIVATE) and shared (MAP_SHARED) mmap files. 2014-07-23 11:25:21 -07:00
boydgreenfield
a309a5f38a Update posix open() call to incl. permissions
This explicitly grants user read/write access to newly-created mmap files. Previously, on some systems files would be created but could not be re-opened as the user lacked sufficient permissions.
2014-05-05 16:42:30 -07:00
boydgreenfield
c210e1255c Clarify newFileSize & mappedSize params in memfiles.open() docs 2014-05-05 14:56:14 -07:00
Araq
fb5ece805f added mapMem/unmapMem to memfiles; untested 2014-03-22 02:51:03 +01:00
Araq
286f166304 case consistency for linux 2013-12-29 03:32:46 +01:00
Araq
92b8fac94a case consistency part 4 2013-12-27 23:10:36 +01:00
Dominik Picheta
a9f2c3ffaf Fixed OSError + recvLine deprecation warnings. 2013-06-27 15:06:30 +01:00
Araq
5c91f6ff2c memfiles compiles again on windows 2013-05-20 03:09:28 +02:00
Araq
ff4a69b624 win64 is a supported target; bugfix: nimrod c -r on windows; stdlib uses wide char versions of the WinAPI 2012-03-04 21:44:56 +01:00