Canonical/Idiomatic in memory files

Russel Winder russel at winder.org.uk
Tue May 28 21:47:55 PDT 2013


On Tue, 2013-05-28 at 13:46 -0400, Jonathan M Davis wrote:
[…]
> Do you mean something like std.mmfile.MmFile which operates on a file as an 
> array in memory using mmap, or do you mean operating on memory that has no 
> connection to a file at all (in which case, I'm not sure why you'd want to use 
> File)? If the former, well use std.file.MmFile. If the latter, I expect that 
> you're out of luck. Unfortunately, std.stdio.File is currently just a wrapper 
> around FILE and is thus limited by what you can do with FILE - that and I 
> don't think that the File API took into consideration the possibility of 
> operating on anything other than an actual file (and I honestly don't know what 
> you'd be trying to do with it where it would make any sense for to operate on 
> anything other than an actual file).

Looks like I am out of luck then. :-(

The context is writing a small program that can be a filter or operate
on files: actually it is the wc program. So it needs to work with opened
files and stdin. That is fine (sort of). The issue comes when writing
unit tests for the code: unit tests should not touch the file system, so
I need a memory buffer backed std.stdio.File for the tests. A mock file
in a sense.As noted earlier Go, Python, all JVM languages have such
things, and it really needs to be part of D. If there really is nothing
like this, I should add a JIRA issue and see if I can create a pull
request later in the summer.

-- 
Russel.
=============================================================================
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder at ekiga.net
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel at winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130529/8bbd967f/attachment.pgp>


More information about the Digitalmars-d mailing list