return file from memory

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri May 25 03:49:29 PDT 2007


Charma wrote:
> Once again i have a problem abusing this forum for help, sorry.

Perhaps you should just start using digitalmars.D.learn, that's what 
it's there for ;)...

> I am looking for a way to return a part of a File in a function without writing it to hdd but sending the part itself as a File.
> Maybe someone has an idea how to do that?
> 
> File myfunction(...requestedPart...)
> {
>   File bigfile = new File(bigfilename, FileMode.In);
>   ...
>   bigfile.read(request, requested part);
>   ...
>   return request;
> }
> 
> Now i want this "request" not to be a string with the content but a File-Type itself without saving it to hdd. I want it to be saved in memory only but be able to handle same like File-type. Anything like that possible?
> Maybe i need to make my own class from File or something?!?
> Thanks for any help!

Any particular reason you want to return it as a File if it's not, you 
know, a _file_?
Perhaps it'd be easier to just change the return type to Stream, and 
return a SliceStream? Or a MemoryStream if you insist on pre-reading the 
data, for example if you're paranoid about write operations changing the 
contents of the file while you're working with it.



More information about the Digitalmars-d mailing list