problem with overwriting Class

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Mon May 28 03:00:51 PDT 2007


Charma wrote:
> Hello,
> I have a problem with overwriting a class. I want to make a class from BufferedFile in which i can use all it's functions but i want the starting position to be shifted to a given position (Vfpos) and to go to a given maximum (Vfsize). For example i got a 100kb-file and i want it to start from position 10kb and load maximum of 20kb, i want it to act as if there is a 20kb-file only and it should go from 10-30 with positions 0-20. I started overwriting the read-functions and adding stuff so that it doesn't read more than the wanted area and so on. My problem is with the position(ulong offset) function. For some reason I can't correctly overwrite it...

Have you considered just using std.stream.SliceStream? It pretty much 
does what you want, but for any stream and any limits (specified as 
constructor arguments).

If you insist on another class, try something like this:
---
class VFile : SliceStream {
     this(...) {
         // base stream, lower & upper bound
         super(new BufferedStream(...), 10*1024, 30*1024);
     }
}
---
Add some constructor arguments for VFile and/or the "new BufferedStream" 
and you're pretty much done...



More information about the Digitalmars-d mailing list