source: trunk/src/ole32/stg_stream.cpp@ 3167

Last change on this file since 3167 was 3167, checked in by davidr, 25 years ago

Ported changes from wine/corel sources

File size: 21.3 KB
Line 
1/* $Id: stg_stream.cpp,v 1.2 2000-03-19 15:33:07 davidr Exp $ */
2/*
3 * Compound Storage (32 bit version)
4 * Stream implementation
5 *
6 * 20/9/99
7 *
8 * Copyright 1999 David J. Raison
9 *
10 * Direct port of Wine Implementation
11 *
12 * This file contains the implementation of the stream interface
13 * for streams contained in a compound storage.
14 *
15 * TODO:
16 * - Support for a transacted mode
17 *
18 * Copyright 1999 Francis Beaudet
19 * Copyright 1999 Thuy Nguyen
20 */
21
22#include "ole32.h"
23#include "heapstring.h"
24#include "debugtools.h"
25#include "storage.h"
26
27#include <assert.h>
28
29DEFAULT_DEBUG_CHANNEL(storage)
30
31
32/*
33 * Virtual function table for the StgStreamImpl class.
34 */
35static ICOM_VTABLE(IStream) StgStreamImpl_Vtbl =
36{
37 ICOM_MSVTABLE_COMPAT_DummyRTTIVALUE
38 StgStreamImpl_QueryInterface,
39 StgStreamImpl_AddRef,
40 StgStreamImpl_Release,
41 StgStreamImpl_Read,
42 StgStreamImpl_Write,
43 StgStreamImpl_Seek,
44 StgStreamImpl_SetSize,
45 StgStreamImpl_CopyTo,
46 StgStreamImpl_Commit,
47 StgStreamImpl_Revert,
48 StgStreamImpl_LockRegion,
49 StgStreamImpl_UnlockRegion,
50 StgStreamImpl_Stat,
51 StgStreamImpl_Clone
52};
53
54/******************************************************************************
55** StgStreamImpl implementation
56*/
57
58/***
59 * This is the constructor for the StgStreamImpl class.
60 *
61 * Params:
62 * parentStorage - Pointer to the storage that contains the stream to open
63 * ownerProperty - Index of the property that points to this stream.
64 */
65StgStreamImpl* StgStreamImpl_Construct(
66 StorageBaseImpl* parentStorage,
67 DWORD grfMode,
68 ULONG ownerProperty)
69{
70 StgStreamImpl* newStream;
71
72 newStream = (StgStreamImpl *)HeapAlloc(GetProcessHeap(), 0, sizeof(StgStreamImpl));
73
74 if (newStream!=0)
75 {
76 /*
77 * Set-up the virtual function table and reference count.
78 */
79 ICOM_VTBL(newStream) = &StgStreamImpl_Vtbl;
80 newStream->ref = 0;
81
82 /*
83 * We want to nail-down the reference to the storage in case the
84 * stream out-lives the storage in the client application.
85 */
86 newStream->parentStorage = parentStorage;
87 IStorage_AddRef((IStorage*)newStream->parentStorage);
88
89 newStream->grfMode = grfMode;
90 newStream->ownerProperty = ownerProperty;
91
92 /*
93 * Start the stream at the begining.
94 */
95 newStream->currentPosition.HighPart = 0;
96 newStream->currentPosition.LowPart = 0;
97
98 /*
99 * Initialize the rest of the data.
100 */
101 newStream->streamSize.HighPart = 0;
102 newStream->streamSize.LowPart = 0;
103 newStream->bigBlockChain = 0;
104 newStream->smallBlockChain = 0;
105
106 /*
107 * Read the size from the property and determine if the blocks forming
108 * this stream are large or small.
109 */
110 StgStreamImpl_OpenBlockChain(newStream);
111 }
112
113 return newStream;
114}
115
116/***
117 * This is the destructor of the StgStreamImpl class.
118 *
119 * This method will clean-up all the resources used-up by the given StgStreamImpl
120 * class. The pointer passed-in to this function will be freed and will not
121 * be valid anymore.
122 */
123void StgStreamImpl_Destroy(StgStreamImpl* This)
124{
125 TRACE("(%p)\n", This);
126
127 /*
128 * Release the reference we are holding on the parent storage.
129 */
130 IStorage_Release((IStorage*)This->parentStorage);
131 This->parentStorage = 0;
132
133 /*
134 * Make sure we clean-up the block chain stream objects that we were using.
135 */
136 if (This->bigBlockChain != 0)
137 {
138 BlockChainStream_Destroy(This->bigBlockChain);
139 This->bigBlockChain = 0;
140 }
141
142 if (This->smallBlockChain != 0)
143 {
144 SmallBlockChainStream_Destroy(This->smallBlockChain);
145 This->smallBlockChain = 0;
146 }
147
148 /*
149 * Finally, free the memory used-up by the class.
150 */
151 HeapFree(GetProcessHeap(), 0, This);
152}
153
154/***
155 * This implements the IUnknown method QueryInterface for this
156 * class
157 */
158HRESULT WINAPI StgStreamImpl_QueryInterface(
159 IStream* iface,
160 REFIID riid, /* [in] */
161 void** ppvObject) /* [iid_is][out] */
162{
163 StgStreamImpl* const This=(StgStreamImpl*)iface;
164
165 /*
166 * Perform a sanity check on the parameters.
167 */
168 if (ppvObject==0)
169 return E_INVALIDARG;
170
171 /*
172 * Initialize the return parameter.
173 */
174 *ppvObject = 0;
175
176 /*
177 * Compare the riid with the interface IDs implemented by this object.
178 */
179 if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
180 {
181 *ppvObject = (IStream*)This;
182 }
183 else if (memcmp(&IID_IStream, riid, sizeof(IID_IStream)) == 0)
184 {
185 *ppvObject = (IStream*)This;
186 }
187
188 /*
189 * Check that we obtained an interface.
190 */
191 if ((*ppvObject)==0)
192 return E_NOINTERFACE;
193
194 /*
195 * Query Interface always increases the reference count by one when it is
196 * successful
197 */
198 StgStreamImpl_AddRef(iface);
199
200 return S_OK;;
201}
202
203/***
204 * This implements the IUnknown method AddRef for this
205 * class
206 */
207ULONG WINAPI StgStreamImpl_AddRef(
208 IStream* iface)
209{
210 StgStreamImpl* const This=(StgStreamImpl*)iface;
211
212 This->ref++;
213
214 return This->ref;
215}
216
217/***
218 * This implements the IUnknown method Release for this
219 * class
220 */
221ULONG WINAPI StgStreamImpl_Release(
222 IStream* iface)
223{
224 StgStreamImpl* const This=(StgStreamImpl*)iface;
225
226 ULONG newRef;
227
228 This->ref--;
229
230 newRef = This->ref;
231
232 /*
233 * If the reference count goes down to 0, perform suicide.
234 */
235 if (newRef==0)
236 {
237 StgStreamImpl_Destroy(This);
238 }
239
240 return newRef;
241}
242
243/***
244 * This method will open the block chain pointed by the property
245 * that describes the stream.
246 * If the stream's size is null, no chain is opened.
247 */
248void StgStreamImpl_OpenBlockChain(
249 StgStreamImpl* This)
250{
251 StgProperty curProperty;
252 BOOL readSucessful;
253
254 /*
255 * Make sure no old object is staying behind.
256 */
257 if (This->smallBlockChain != 0)
258 {
259 SmallBlockChainStream_Destroy(This->smallBlockChain);
260 This->smallBlockChain = 0;
261 }
262
263 if (This->bigBlockChain != 0)
264 {
265 BlockChainStream_Destroy(This->bigBlockChain);
266 This->bigBlockChain = 0;
267 }
268
269 /*
270 * Read the information from the property.
271 */
272 readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
273 This->ownerProperty,
274 &curProperty);
275
276 if (readSucessful)
277 {
278 This->streamSize = curProperty.size;
279
280 /*
281 * This code supports only streams that are <32 bits in size.
282 */
283 assert(This->streamSize.HighPart == 0);
284
285 if(curProperty.startingBlock == BLOCK_END_OF_CHAIN)
286 {
287 assert( (This->streamSize.HighPart == 0) && (This->streamSize.LowPart == 0) );
288 }
289 else
290 {
291 if ( (This->streamSize.HighPart == 0) &&
292 (This->streamSize.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
293 {
294 This->smallBlockChain = SmallBlockChainStream_Construct(
295 This->parentStorage->ancestorStorage,
296 This->ownerProperty);
297 }
298 else
299 {
300 This->bigBlockChain = BlockChainStream_Construct(
301 This->parentStorage->ancestorStorage,
302 NULL,
303 This->ownerProperty);
304 }
305 }
306 }
307}
308
309/***
310 * This method is part of the ISequentialStream interface.
311 *
312 * If reads a block of information from the stream at the current
313 * position. It then moves the current position at the end of the
314 * read block
315 *
316 * See the documentation of ISequentialStream for more info.
317 */
318HRESULT WINAPI StgStreamImpl_Read(
319 IStream* iface,
320 void* pv, /* [length_is][size_is][out] */
321 ULONG cb, /* [in] */
322 ULONG* pcbRead) /* [out] */
323{
324 StgStreamImpl* const This=(StgStreamImpl*)iface;
325
326 ULONG bytesReadBuffer;
327 ULONG bytesToReadFromBuffer;
328
329 TRACE("(%p, %p, %ld, %p)\n",
330 iface, pv, cb, pcbRead);
331
332 /*
333 * If the caller is not interested in the nubmer of bytes read,
334 * we use another buffer to avoid "if" statements in the code.
335 */
336 if (pcbRead==0)
337 pcbRead = &bytesReadBuffer;
338
339 /*
340 * Using the known size of the stream, calculate the number of bytes
341 * to read from the block chain
342 */
343 bytesToReadFromBuffer = MIN( This->streamSize.LowPart - This->currentPosition.LowPart, cb);
344
345 /*
346 * Depending on the type of chain that was opened when the stream was constructed,
347 * we delegate the work to the method that read the block chains.
348 */
349 if (This->smallBlockChain!=0)
350 {
351 SmallBlockChainStream_ReadAt(This->smallBlockChain,
352 This->currentPosition,
353 bytesToReadFromBuffer,
354 pv,
355 pcbRead);
356
357 }
358 else if (This->bigBlockChain!=0)
359 {
360 BlockChainStream_ReadAt(This->bigBlockChain,
361 This->currentPosition,
362 bytesToReadFromBuffer,
363 pv,
364 pcbRead);
365 }
366 else
367 {
368 /*
369 * Small and big block chains are both NULL. This case will happen
370 * when a stream starts with BLOCK_END_OF_CHAIN and has size zero.
371 */
372
373 *pcbRead = 0;
374 return S_OK;
375 }
376
377 /*
378 * We should always be able to read the proper amount of data from the
379 * chain.
380 */
381 assert(bytesToReadFromBuffer == *pcbRead);
382
383 /*
384 * Advance the pointer for the number of positions read.
385 */
386 This->currentPosition.LowPart += *pcbRead;
387
388 /*
389 * The function returns S_OK if the buffer was filled completely
390 * it returns S_FALSE if the end of the stream is reached before the
391 * buffer is filled
392 */
393 if(*pcbRead == cb)
394 return S_OK;
395
396 return S_FALSE;
397}
398
399/***
400 * This method is part of the ISequentialStream interface.
401 *
402 * It writes a block of information to the stream at the current
403 * position. It then moves the current position at the end of the
404 * written block. If the stream is too small to fit the block,
405 * the stream is grown to fit.
406 *
407 * See the documentation of ISequentialStream for more info.
408 */
409HRESULT WINAPI StgStreamImpl_Write(
410 IStream* iface,
411 const void* pv, /* [size_is][in] */
412 ULONG cb, /* [in] */
413 ULONG* pcbWritten) /* [out] */
414{
415 StgStreamImpl* const This=(StgStreamImpl*)iface;
416
417 ULARGE_INTEGER newSize;
418 ULONG bytesWritten = 0;
419
420 TRACE("(%p, %p, %ld, %p)\n",
421 iface, pv, cb, pcbWritten);
422
423 /*
424 * If the caller is not interested in the number of bytes written,
425 * we use another buffer to avoid "if" statements in the code.
426 */
427 if (pcbWritten == 0)
428 pcbWritten = &bytesWritten;
429
430 /*
431 * Initialize the out parameter
432 */
433 *pcbWritten = 0;
434
435 /*
436 * Do we have permission to write to this stream?
437 */
438 if (!(This->grfMode & (STGM_WRITE | STGM_READWRITE)))
439 return STG_E_ACCESSDENIED;
440
441 if (cb == 0)
442 {
443 return S_OK;
444 }
445 else
446 {
447 newSize.HighPart = 0;
448 newSize.LowPart = This->currentPosition.LowPart + cb;
449 }
450
451 /*
452 * Verify if we need to grow the stream
453 */
454 if (newSize.LowPart > This->streamSize.LowPart)
455 {
456 /* grow stream */
457 IStream_SetSize(iface, newSize);
458 }
459
460 /*
461 * Depending on the type of chain that was opened when the stream was constructed,
462 * we delegate the work to the method that readwrites to the block chains.
463 */
464 if (This->smallBlockChain!=0)
465 {
466 SmallBlockChainStream_WriteAt(This->smallBlockChain,
467 This->currentPosition,
468 cb,
469 pv,
470 pcbWritten);
471
472 }
473 else if (This->bigBlockChain!=0)
474 {
475 BlockChainStream_WriteAt(This->bigBlockChain,
476 This->currentPosition,
477 cb,
478 pv,
479 pcbWritten);
480 }
481 else
482 assert(FALSE);
483
484 /*
485 * Advance the position pointer for the number of positions written.
486 */
487 This->currentPosition.LowPart += *pcbWritten;
488
489 return S_OK;
490}
491
492/***
493 * This method is part of the IStream interface.
494 *
495 * It will move the current stream pointer according to the parameters
496 * given.
497 *
498 * See the documentation of IStream for more info.
499 */
500HRESULT WINAPI StgStreamImpl_Seek(
501 IStream* iface,
502 LARGE_INTEGER dlibMove, /* [in] */
503 DWORD dwOrigin, /* [in] */
504 ULARGE_INTEGER* plibNewPosition) /* [out] */
505{
506 StgStreamImpl* const This=(StgStreamImpl*)iface;
507
508 ULARGE_INTEGER newPosition;
509
510 TRACE("(%p, %ld, %ld, %p)\n",
511 iface, dlibMove.LowPart, dwOrigin, plibNewPosition);
512
513 /*
514 * The caller is allowed to pass in NULL as the new position return value.
515 * If it happens, we assign it to a dynamic variable to avoid special cases
516 * in the code below.
517 */
518 if (plibNewPosition == 0)
519 {
520 plibNewPosition = &newPosition;
521 }
522
523 /*
524 * The file pointer is moved depending on the given "function"
525 * parameter.
526 */
527 switch (dwOrigin)
528 {
529 case STREAM_SEEK_SET:
530 plibNewPosition->HighPart = 0;
531 plibNewPosition->LowPart = 0;
532 break;
533 case STREAM_SEEK_CUR:
534 *plibNewPosition = This->currentPosition;
535 break;
536 case STREAM_SEEK_END:
537 *plibNewPosition = This->streamSize;
538 break;
539 default:
540 return STG_E_INVALIDFUNCTION;
541 }
542
543#if SIZEOF_LONG_LONG >= 8
544 plibNewPosition->QuadPart += dlibMove.QuadPart;
545#else
546 /*
547 * do some multiword arithmetic:
548 * treat HighPart as a signed value
549 * treat LowPart as unsigned
550 * NOTE: this stuff is two's complement specific!
551 */
552 if (dlibMove.HighPart < 0) { /* dlibMove is < 0 */
553 /* calculate the absolute value of dlibMove ... */
554 dlibMove.HighPart = -dlibMove.HighPart;
555 dlibMove.LowPart ^= -1;
556 /* ... and subtract with carry */
557 if (dlibMove.LowPart > plibNewPosition->LowPart) {
558 /* carry needed, This accounts for any underflows at [1]*/
559 plibNewPosition->HighPart -= 1;
560 }
561 plibNewPosition->LowPart -= dlibMove.LowPart; /* [1] */
562 plibNewPosition->HighPart -= dlibMove.HighPart;
563 } else {
564 /* add directly */
565 int initialLowPart = plibNewPosition->LowPart;
566 plibNewPosition->LowPart += dlibMove.LowPart;
567 if((plibNewPosition->LowPart < initialLowPart) ||
568 (plibNewPosition->LowPart < dlibMove.LowPart)) {
569 /* LowPart has rolled over => add the carry digit to HighPart */
570 plibNewPosition->HighPart++;
571 }
572 plibNewPosition->HighPart += dlibMove.HighPart;
573 }
574 /*
575 * Check if we end-up before the beginning of the file. That should
576 * trigger an error.
577 */
578 if (plibNewPosition->HighPart < 0) {
579 return STG_E_INVALIDPOINTER;
580 }
581
582 /*
583 * We currently don't support files with offsets of >32 bits.
584 * Note that we have checked for a negative offset already
585 */
586 assert(plibNewPosition->HighPart <= 0);
587
588#endif
589
590 /*
591 * tell the caller what we calculated
592 */
593 This->currentPosition = *plibNewPosition;
594
595 return S_OK;
596}
597
598/***
599 * This method is part of the IStream interface.
600 *
601 * It will change the size of a stream.
602 *
603 * TODO: Switch from small blocks to big blocks and vice versa.
604 *
605 * See the documentation of IStream for more info.
606 */
607HRESULT WINAPI StgStreamImpl_SetSize(
608 IStream* iface,
609 ULARGE_INTEGER libNewSize) /* [in] */
610{
611 StgStreamImpl* const This=(StgStreamImpl*)iface;
612
613 StgProperty curProperty;
614 BOOL Success;
615
616 TRACE("(%p, %ld)\n", iface, libNewSize.LowPart);
617
618 /*
619 * As documented.
620 */
621 if (libNewSize.HighPart != 0)
622 return STG_E_INVALIDFUNCTION;
623
624 /*
625 * Do we have permission?
626 */
627 if (!(This->grfMode & (STGM_WRITE | STGM_READWRITE)))
628 return STG_E_ACCESSDENIED;
629
630 if (This->streamSize.LowPart == libNewSize.LowPart)
631 return S_OK;
632
633 /*
634 * This will happen if we're creating a stream
635 */
636 if ((This->smallBlockChain == 0) && (This->bigBlockChain == 0))
637 {
638 if (libNewSize.LowPart < LIMIT_TO_USE_SMALL_BLOCK)
639 {
640 This->smallBlockChain = SmallBlockChainStream_Construct(
641 This->parentStorage->ancestorStorage,
642 This->ownerProperty);
643 }
644 else
645 {
646 This->bigBlockChain = BlockChainStream_Construct(
647 This->parentStorage->ancestorStorage,
648 NULL,
649 This->ownerProperty);
650 }
651 }
652
653 /*
654 * Read this stream's property to see if it's small blocks or big blocks
655 */
656 Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
657 This->ownerProperty,
658 &curProperty);
659 /*
660 * Determine if we have to switch from small to big blocks or vice versa
661 */
662 if ( (This->smallBlockChain!=0) &&
663 (curProperty.size.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
664 {
665 if (libNewSize.LowPart >= LIMIT_TO_USE_SMALL_BLOCK)
666 {
667 /*
668 * Transform the small block chain into a big block chain
669 */
670 This->bigBlockChain = Storage32Impl_SmallBlocksToBigBlocks(
671 This->parentStorage->ancestorStorage,
672 &This->smallBlockChain);
673 }
674 }
675
676 if (This->smallBlockChain!=0)
677 {
678 Success = SmallBlockChainStream_SetSize(This->smallBlockChain, libNewSize);
679 }
680 else
681 {
682 Success = BlockChainStream_SetSize(This->bigBlockChain, libNewSize);
683 }
684
685 /*
686 * Write to the property the new information about this stream
687 */
688 Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
689 This->ownerProperty,
690 &curProperty);
691
692 curProperty.size.HighPart = libNewSize.HighPart;
693 curProperty.size.LowPart = libNewSize.LowPart;
694
695 if (Success)
696 {
697 StorageImpl_WriteProperty(This->parentStorage->ancestorStorage,
698 This->ownerProperty,
699 &curProperty);
700 }
701
702 This->streamSize = libNewSize;
703
704 return S_OK;
705}
706
707/***
708 * This method is part of the IStream interface.
709 *
710 * It will copy the 'cb' Bytes to 'pstm' IStream.
711 *
712 * See the documentation of IStream for more info.
713 */
714HRESULT WINAPI StgStreamImpl_CopyTo(
715 IStream* iface,
716 IStream* pstm, /* [unique][in] */
717 ULARGE_INTEGER cb, /* [in] */
718 ULARGE_INTEGER* pcbRead, /* [out] */
719 ULARGE_INTEGER* pcbWritten) /* [out] */
720{
721 HRESULT hr = S_OK;
722 BYTE tmpBuffer[128];
723 ULONG bytesRead, bytesWritten, copySize;
724 ULARGE_INTEGER totalBytesRead;
725 ULARGE_INTEGER totalBytesWritten;
726
727 TRACE("(%p, %p, %ld, %p, %p)\n",
728 iface, pstm, cb.LowPart, pcbRead, pcbWritten);
729
730 /*
731 * Sanity check
732 */
733 if ( pstm == 0 )
734 return STG_E_INVALIDPOINTER;
735
736 totalBytesRead.LowPart = totalBytesRead.HighPart = 0;
737 totalBytesWritten.LowPart = totalBytesWritten.HighPart = 0;
738
739 /*
740 * use stack to store data temporarly
741 * there is surely more performant way of doing it, for now this basic
742 * implementation will do the job
743 */
744 while ( cb.LowPart > 0 )
745 {
746 if ( cb.LowPart >= 128 )
747 copySize = 128;
748 else
749 copySize = cb.LowPart;
750
751 IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
752
753 totalBytesRead.LowPart += bytesRead;
754
755 IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
756
757 totalBytesWritten.LowPart += bytesWritten;
758
759 /*
760 * Check that read & write operations were succesfull
761 */
762 if (bytesRead != bytesWritten)
763 {
764 hr = STG_E_MEDIUMFULL;
765 break;
766 }
767
768 if (bytesRead!=copySize)
769 cb.LowPart = 0;
770 else
771 cb.LowPart -= bytesRead;
772 }
773
774 /*
775 * Update number of bytes read and written
776 */
777 if (pcbRead)
778 {
779 pcbRead->LowPart = totalBytesRead.LowPart;
780 pcbRead->HighPart = totalBytesRead.HighPart;
781 }
782
783 if (pcbWritten)
784 {
785 pcbWritten->LowPart = totalBytesWritten.LowPart;
786 pcbWritten->HighPart = totalBytesWritten.HighPart;
787 }
788 return hr;
789}
790
791/***
792 * This method is part of the IStream interface.
793 *
794 * For streams contained in structured storages, this method
795 * does nothing. This is what the documentation tells us.
796 *
797 * See the documentation of IStream for more info.
798 */
799HRESULT WINAPI StgStreamImpl_Commit(
800 IStream* iface,
801 DWORD grfCommitFlags) /* [in] */
802{
803 return S_OK;
804}
805
806/***
807 * This method is part of the IStream interface.
808 *
809 * For streams contained in structured storages, this method
810 * does nothing. This is what the documentation tells us.
811 *
812 * See the documentation of IStream for more info.
813 */
814HRESULT WINAPI StgStreamImpl_Revert(
815 IStream* iface)
816{
817 return S_OK;
818}
819
820HRESULT WINAPI StgStreamImpl_LockRegion(
821 IStream* iface,
822 ULARGE_INTEGER libOffset, /* [in] */
823 ULARGE_INTEGER cb, /* [in] */
824 DWORD dwLockType) /* [in] */
825{
826 FIXME("not implemented!\n");
827 return E_NOTIMPL;
828}
829
830HRESULT WINAPI StgStreamImpl_UnlockRegion(
831 IStream* iface,
832 ULARGE_INTEGER libOffset, /* [in] */
833 ULARGE_INTEGER cb, /* [in] */
834 DWORD dwLockType) /* [in] */
835{
836 FIXME("not implemented!\n");
837 return E_NOTIMPL;
838}
839
840/***
841 * This method is part of the IStream interface.
842 *
843 * This method returns information about the current
844 * stream.
845 *
846 * See the documentation of IStream for more info.
847 */
848HRESULT WINAPI StgStreamImpl_Stat(
849 IStream* iface,
850 STATSTG* pstatstg, /* [out] */
851 DWORD grfStatFlag) /* [in] */
852{
853 StgStreamImpl* const This=(StgStreamImpl*)iface;
854
855 StgProperty curProperty;
856 BOOL readSucessful;
857
858 /*
859 * Read the information from the property.
860 */
861 readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
862 This->ownerProperty,
863 &curProperty);
864
865 if (readSucessful)
866 {
867 StorageUtl_CopyPropertyToSTATSTG(pstatstg,
868 &curProperty,
869 grfStatFlag);
870
871 pstatstg->grfMode = This->grfMode;
872
873 return S_OK;
874 }
875
876 return E_FAIL;
877}
878
879HRESULT WINAPI StgStreamImpl_Clone(
880 IStream* iface,
881 IStream** ppstm) /* [out] */
882{
883 FIXME("not implemented!\n");
884 return E_NOTIMPL;
885}
Note: See TracBrowser for help on using the repository browser.