# MemFile: In-memory fake File

MemFile in [lib/memfile.fs] is a structure that extends File [doc/sys/file] and
provides read/write capability to a memory area. When it reaches the end of its
buffer, reads will yield EOF and writes will fail.

MemFile implements all File methods, including "resize". However, this
implementation is meant to allow ":truncate" to work and isn't meant to allow
buffer enlargement. In other words, use "resize" responsibly or else you'll
corrupt your memory.

Fields:

ptr  Pointer to the memory where this buffer lives at

Words:

:new ( a u -- hdl )
  Allocate a new MemFile pointing to address range "a u".

:newbuf ( sz -- hdl )
  Allocate a new buffer of "sz" bytes and then call :new with it.

:range ( hdl -- a u )
  Return the range represented by the whole buffer.

:eof? ( hdl -- f )
  Whether ptr = )buf.

:rewind ( hdl -- )
  Set "pos" to 0.
