mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-10-27 14:35:07 +01:00
* patch from 15003 from M spiller, reverting now implemented.
git-svn-id: trunk@14078 -
This commit is contained in:
parent
2295a9f23b
commit
6ed7d33569
@ -945,8 +945,9 @@ type
|
|||||||
{ Implements OLE IStream on TStream }
|
{ Implements OLE IStream on TStream }
|
||||||
TStreamAdapter = class(TInterfacedObject, IStream)
|
TStreamAdapter = class(TInterfacedObject, IStream)
|
||||||
private
|
private
|
||||||
FStream: TStream;
|
FStream : TStream;
|
||||||
FOwnership: TStreamOwnership;
|
FOwnership : TStreamOwnership;
|
||||||
|
m_bReverted: Boolean;
|
||||||
public
|
public
|
||||||
constructor Create(Stream: TStream; Ownership: TStreamOwnership = soReference);
|
constructor Create(Stream: TStream; Ownership: TStreamOwnership = soReference);
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
|||||||
@ -821,6 +821,9 @@ begin
|
|||||||
inherited Create;
|
inherited Create;
|
||||||
FStream:=Stream;
|
FStream:=Stream;
|
||||||
FOwnership:=Ownership;
|
FOwnership:=Ownership;
|
||||||
|
m_bReverted:=false; // mantis 15003
|
||||||
|
// http://www.tech-archive.net/Archive/German/microsoft.public.de.vc/2005-08/msg00791.html
|
||||||
|
// http://code.google.com/p/ddab-lib/wiki/TPJIStreamWrapper
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -836,6 +839,11 @@ function TStreamAdapter.Read(pv: Pointer; cb: DWORD; pcbRead: PDWORD): HResult;
|
|||||||
var
|
var
|
||||||
readcount: Longint;
|
readcount: Longint;
|
||||||
begin
|
begin
|
||||||
|
if m_bReverted then
|
||||||
|
begin
|
||||||
|
Result := STG_E_REVERTED;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
if pv = nil then
|
if pv = nil then
|
||||||
begin
|
begin
|
||||||
Result := E_INVALIDARG;
|
Result := E_INVALIDARG;
|
||||||
@ -851,6 +859,11 @@ function TStreamAdapter.Write(pv: Pointer; cb: DWORD; pcbWritten: PDWORD): HResu
|
|||||||
var
|
var
|
||||||
writecount: Longint;
|
writecount: Longint;
|
||||||
begin
|
begin
|
||||||
|
if m_bReverted then
|
||||||
|
begin
|
||||||
|
Result := STG_E_REVERTED;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
if pv = nil then
|
if pv = nil then
|
||||||
begin
|
begin
|
||||||
Result := E_INVALIDARG;
|
Result := E_INVALIDARG;
|
||||||
@ -866,6 +879,11 @@ function TStreamAdapter.Seek(dlibMove: Largeint; dwOrigin: Longint; out libNewPo
|
|||||||
var
|
var
|
||||||
newpos: Int64;
|
newpos: Int64;
|
||||||
begin
|
begin
|
||||||
|
if m_bReverted then
|
||||||
|
begin
|
||||||
|
Result := STG_E_REVERTED;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
case dwOrigin of
|
case dwOrigin of
|
||||||
STREAM_SEEK_SET: newpos := FStream.Seek(dlibMove, soBeginning);
|
STREAM_SEEK_SET: newpos := FStream.Seek(dlibMove, soBeginning);
|
||||||
STREAM_SEEK_CUR: newpos := FStream.Seek(dlibMove, soCurrent);
|
STREAM_SEEK_CUR: newpos := FStream.Seek(dlibMove, soCurrent);
|
||||||
@ -879,42 +897,59 @@ end;
|
|||||||
|
|
||||||
function TStreamAdapter.SetSize(libNewSize: Largeint): HResult; stdcall;
|
function TStreamAdapter.SetSize(libNewSize: Largeint): HResult; stdcall;
|
||||||
begin
|
begin
|
||||||
|
if m_bReverted then
|
||||||
|
begin
|
||||||
|
Result := STG_E_REVERTED;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
runerror(217);
|
runerror(217);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TStreamAdapter.CopyTo(stm: IStream; cb: Largeint; out cbRead: Largeint; out cbWritten: Largeint): HResult; stdcall;
|
function TStreamAdapter.CopyTo(stm: IStream; cb: Largeint; out cbRead: Largeint; out cbWritten: Largeint): HResult; stdcall;
|
||||||
begin
|
begin
|
||||||
|
if m_bReverted then
|
||||||
|
begin
|
||||||
|
Result := STG_E_REVERTED;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
runerror(217);
|
runerror(217);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TStreamAdapter.Commit(grfCommitFlags: Longint): HResult; stdcall;
|
function TStreamAdapter.Commit(grfCommitFlags: Longint): HResult; stdcall;
|
||||||
begin
|
begin
|
||||||
runerror(217);
|
if m_bReverted then
|
||||||
|
Result := STG_E_REVERTED
|
||||||
|
else
|
||||||
|
Result := S_OK;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TStreamAdapter.Revert: HResult; stdcall;
|
function TStreamAdapter.Revert: HResult; stdcall;
|
||||||
begin
|
begin
|
||||||
runerror(217);
|
m_bReverted := True;
|
||||||
|
Result := S_OK;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TStreamAdapter.LockRegion(libOffset: Largeint; cb: Largeint; dwLockType: Longint): HResult; stdcall;
|
function TStreamAdapter.LockRegion(libOffset: Largeint; cb: Largeint; dwLockType: Longint): HResult; stdcall;
|
||||||
begin
|
begin
|
||||||
runerror(217);
|
Result := STG_E_INVALIDFUNCTION;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TStreamAdapter.UnlockRegion(libOffset: Largeint; cb: Largeint; dwLockType: Longint): HResult; stdcall;
|
function TStreamAdapter.UnlockRegion(libOffset: Largeint; cb: Largeint; dwLockType: Longint): HResult; stdcall;
|
||||||
begin
|
begin
|
||||||
runerror(217);
|
Result := STG_E_INVALIDFUNCTION;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TStreamAdapter.Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult; stdcall;
|
function TStreamAdapter.Stat(out statstg: TStatStg; grfStatFlag: Longint): HResult; stdcall;
|
||||||
begin
|
begin
|
||||||
|
if m_bReverted then
|
||||||
|
begin
|
||||||
|
Result := STG_E_REVERTED;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
if grfStatFlag in [STATFLAG_DEFAULT,STATFLAG_NOOPEN,STATFLAG_NONAME] then
|
if grfStatFlag in [STATFLAG_DEFAULT,STATFLAG_NOOPEN,STATFLAG_NONAME] then
|
||||||
begin
|
begin
|
||||||
if @statstg <> nil then
|
if @statstg <> nil then
|
||||||
@ -937,6 +972,11 @@ end;
|
|||||||
|
|
||||||
function TStreamAdapter.Clone(out stm: IStream): HResult; stdcall;
|
function TStreamAdapter.Clone(out stm: IStream): HResult; stdcall;
|
||||||
begin
|
begin
|
||||||
|
if m_bReverted then
|
||||||
|
begin
|
||||||
|
Result := STG_E_REVERTED;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
runerror(217);
|
runerror(217);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user