Tango file i/o
Lars Ivar Igesund
larsivar at igesund.net
Wed Mar 19 04:23:35 PDT 2008
Jason House wrote:
> torhu wrote:
>
>> Jason House wrote:
>>> I'm having trouble writing a unit test to check code that communicates
>>> via
>>> standard in and standard out. Attached to this post is my a reduced
>>> form
>>> of my problems. Can anyone tell me what's going wrong? (The assert in
>>> the code fails)
>>
>> You need to rewind the file before starting to read after writing:
>>
>> fakeConsole.seek(0);
>
> I interpret that to mean that writing to the file affects the read stream
> and reading affects the write stream. I need to decouple those because
> reading and writing should be more or less independent of each other.
Yes, because your TempFile is a Conduit that provides both the input and
output stream.
>
> It sounds like if I open up a file twice, once for writing and once for
> reading, that I can get independent access into the file.
Yes.
> The real test
> is
> multi-threaded with reading and writing done asynchronously. With
> independent file classes, will EOF be a problem? AKA, if a read occurs
> when a write is in progress.
You should lock your resources (files) while writing.
--
Lars Ivar Igesund
blog at http://larsivi.net
DSource, #d.tango & #D: larsivi
Dancing the Tango
More information about the Digitalmars-d-learn
mailing list