You do not need the using
statement at all, so get rid of it. You are overriding the 64-bit Seek()
method. That is all you need to do. You get the 32-bit Seek()
method for free since it is a public method of TStream
and you are using public
inheritance on your derived class. You do not have to declare anything to get or use the 32-bit Seek()
method. As long as you do not override it, it will internally call your 64-bit overriden Seek()
if called.
class TTempFileStream : public TStream
{
...
public:
...
virtual __int64 __fastcall Seek(const __int64 Offset, TSeekOrigin Origin)
{
return 0; // for simplicity!
}
...
};
FYI, if all you need is to delete the temp file when the stream is closed, you don't need a derived class at all. You can use the RTL's THandleStream
as-is instead, passing it a HANDLE
from the Win32 API CreateFile()
function, where you specify the FILE_FLAG_DELETE_ON_CLOSE
flag to CreateFile()
.