Re: [Alephmodular-devel] CFileDesc landed
Status: Pre-Alpha
Brought to you by:
brefin
From: Br'fin <br...@ma...> - 2003-02-13 17:23:43
|
On Wednesday, February 12, 2003, at 06:45 PM, Br'fin wrote: >>> Ah, I didn't realize that that processing was a feature of AlephOne >>> specifically. I'll have to look into it. Does A1 deal with a >>> MacBinary of a map file too? Or does that still need to be >>> explicitly split out into two files? >> >> It looks like (though I have not tested this myself) that it should >> indeed be able to read both forks from the single MacBinary file, no >> need to split. [snip] > That's just cute. Insanely cute :) > > Hsm. I'm not sure how on earth I would do that with iostreams. I mean, > I know how I might do it, but I honestly have no idea as to whether I > can do it that way, I don't know which kinds of methods I can override > safely. Durn C++. > Pester some folks on the newsgroups, and I think I understand what I would need to do on my end now. -Jeremy Parsons Newsgroups: comp.lang.c++ Subject: Re: Limiting an ifstream to part of a file? Simon Turner wrote: Br'fin wrote: > "White Wolf" wrote: > > > "Br'fin" wrote: > > > I'm trying to find a safe way to open an ifstream or equivalent > > > subclass, but set it up to that it is limited to only a portion of a > > > file. > > > <snip> > > > > IMHO you will need to make a custom stream buffer to achieve that. > > > > WW > > Offhand, subclassing filebuf looks straightforward. As would > interfering with its seek and other methods to treat the artificial > bounds limits as actual ones. > > But I'm having trouble understanding how I would use this subclass > with an ifstream. You can create an ifstream to use with your custom streambuf by passing a pointer to the constructor, like: my_restricted_filebuf mf( "file.ext" ); std::ifstream restricted_file( &mf ); If you have an existing ifstream you want to redirect to your custom streambuf, you can use: my_file.rdbuf( &mf ); > > It seems like I would need to ditch ifstream and use the > basic_ifstream code as a sample or nearly verbatim for writing my > own istream subclass Fortunately not, although you need to take care of the streambuf's lifetime if you do it this way. > :/ PS.I just looked this up in my copy of "The C++ Standard Library", by Nicolai Josuttis. If you're doing a lot of tricky iostreams work, it might be time to go shopping. ;-D > > -Jeremy Parsons |