windows.streams: attempt to determine stream size because GdipCreateBitmapFromStream requires its IStream to report it

db4
Joe Groff 2010-07-06 22:35:49 -07:00
parent 780c190d69
commit 5a3b6960e0
1 changed files with 43 additions and 17 deletions

View File

@ -69,12 +69,20 @@ SPECIALIZED-ARRAY: uchar
:: IStream-unlock-region ( stream offset cb lock-type -- hresult ) :: IStream-unlock-region ( stream offset cb lock-type -- hresult )
STG_E_INVALIDFUNCTION ; STG_E_INVALIDFUNCTION ;
FROM: io.ports => tell-handle ;
:: stream-size ( stream -- size )
stream stream-tell :> old-pos
0 seek-end stream stream-seek
stream handle>> tell-handle :> size
old-pos seek-absolute stream stream-seek
size ;
:: IStream-stat ( stream out-stat stat-flag -- hresult ) :: IStream-stat ( stream out-stat stat-flag -- hresult )
[ [
out-stat out-stat
f >>pwcsName f >>pwcsName
STGTY_STREAM >>type STGTY_STREAM >>type
0 >>cbSize stream stream-size >>cbSize
FILETIME <struct> >>mtime FILETIME <struct> >>mtime
FILETIME <struct> >>ctime FILETIME <struct> >>ctime
FILETIME <struct> >>atime FILETIME <struct> >>atime
@ -83,28 +91,46 @@ SPECIALIZED-ARRAY: uchar
GUID_NULL >>clsid GUID_NULL >>clsid
0 >>grfStateBits 0 >>grfStateBits
0 >>reserved 0 >>reserved
drop
S_OK
] with-hresult ; ] with-hresult ;
:: IStream-clone ( out-clone-stream -- hresult ) :: IStream-clone ( out-clone-stream -- hresult )
f out-clone-stream 0 void* set-alien-value f out-clone-stream 0 void* set-alien-value
STG_E_INVALIDFUNCTION ; STG_E_INVALIDFUNCTION ;
MEMO: stream-wrapper ( -- wrapper ) USE: tools.annotations
{ : watch-istream-callbacks ( -- )
{ IStream { \ IStream-read watch
[ IStream-read ] \ IStream-write watch
[ IStream-write ] \ IStream-seek watch
[ IStream-seek ] \ IStream-set-size watch
[ IStream-set-size ] \ IStream-copy-to watch
[ IStream-copy-to ] \ IStream-commit watch
[ IStream-commit ] \ IStream-revert watch
[ IStream-revert ] \ IStream-lock-region watch
[ IStream-lock-region ] \ IStream-unlock-region watch
[ IStream-unlock-region ] \ IStream-stat watch
[ IStream-stat ] \ IStream-clone watch ;
[ IStream-clone ]
} } CONSTANT: stream-wrapper
} <com-wrapper> ; $[
{
{ IStream {
[ IStream-read ]
[ IStream-write ]
[ IStream-seek ]
[ IStream-set-size ]
[ IStream-copy-to ]
[ IStream-commit ]
[ IStream-revert ]
[ IStream-lock-region ]
[ IStream-unlock-region ]
[ IStream-stat ]
[ IStream-clone ]
} }
} <com-wrapper>
]
PRIVATE> PRIVATE>