TStreamAdapter not implemented + partial patch
Original Reporter info from Mantis: mspiller
-
Reporter name:
Original Reporter info from Mantis: mspiller
- Reporter name:
Description:
TStreamAdapter is not implemented (reports runerror).
I have implemented read, write, seek and stat for my own project from scratch.
The trickiest part was http://msdn2.microsoft.com/en-us/library/aa380045(VS.85).aspx.
you can merge it with streams.inc:
function TStreamAdapter.Read(pv: Pointer; cb: DWORD; pcbRead: PDWORD): HResult; stdcall;
var
readcount: Longint;
begin
if pv = nil then
begin
Result := E_INVALIDARG;
Exit;
end;
readcount := FStream.Read(pv^, cb);
if pcbRead <> nil then pcbRead^ := readcount;
Result := S_OK;
end;
function TStreamAdapter.Write(pv: Pointer; cb: DWORD; pcbWritten: PDWORD): HResult; stdcall;
var
writecount: Longint;
begin
if pv = nil then
begin
Result := E_INVALIDARG;
Exit;
end;
writecount := FStream.Write(pv^, cb);
if pcbWritten <> nil then pcbWritten^ := writecount;
Result := S_OK;
end;
function TStreamAdapter.Seek(dlibMove: Largeint; dwOrigin: Longint; out libNewPosition: Largeint): HResult; stdcall;
var
newpos: Int64;
begin
case dwOrigin of
STREAM_SEEK_SET: newpos := FStream.Seek(dlibMove, soBeginning);
STREAM_SEEK_CUR: newpos := FStream.Seek(dlibMove, soCurrent);
STREAM_SEEK_END: newpos := FStream.Seek(dlibMove, soEnd);
else begin Result := E_INVALIDARG; exit; end;
end;
if @libNewPosition <> nil then
libNewPosition := newpos;
Result := S_OK;
end;
function TStreamAdapter.Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult; stdcall;
begin
if grfStatFlag in [STATFLAG_DEFAULT,STATFLAG_NOOPEN,STATFLAG_NONAME] then
begin
if @statstg <> nil then
begin
ZeroMemory(@statstg, sizeof(TStatStg));
{ //TODO handle pwcsName
if grfStatFlag = STATFLAG_DEFAULT then
runerror(217) //Result := STG_E_INVALIDFLAG
}
statstg.dwType := STGTY_STREAM;
statstg.cbSize := FStream.Size;
statstg.grfLocksSupported := LOCK_WRITE;
end;
Result := S_OK;
end else
Result := STG_E_INVALIDFLAG;
end;
Mantis conversion info:
- Mantis ID: 10608
- Version: 2.3.1
- Fixed in revision: 13988 (#09b22de9)