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,13 +91,30 @@ 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-read watch
\ IStream-write watch
\ IStream-seek watch
\ IStream-set-size watch
\ IStream-copy-to watch
\ IStream-commit watch
\ IStream-revert watch
\ IStream-lock-region watch
\ IStream-unlock-region watch
\ IStream-stat watch
\ IStream-clone watch ;
CONSTANT: stream-wrapper
$[
{ {
{ IStream { { IStream {
[ IStream-read ] [ IStream-read ]
@ -104,7 +129,8 @@ MEMO: stream-wrapper ( -- wrapper )
[ IStream-stat ] [ IStream-stat ]
[ IStream-clone ] [ IStream-clone ]
} } } }
} <com-wrapper> ; } <com-wrapper>
]
PRIVATE> PRIVATE>