wined3d: Properly compare integers in wined3d_bo_slab_vk_compare().
[wine.git] / dlls / itss / storage.c
blobee5432d4d61b11ff87716b4f8d43015be934ad16
1 /*
2 * ITSS Storage implementation
4 * Copyright 2004 Mike McCormack
6 * see http://bonedaddy.net/pabs3/hhm/#chmspec
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #include <stdarg.h>
25 #include <stdio.h>
27 #define COBJMACROS
29 #include "windef.h"
30 #include "winbase.h"
31 #include "winuser.h"
32 #include "ole2.h"
34 #include "chm_lib.h"
35 #include "itsstor.h"
37 #include "wine/itss.h"
38 #include "wine/debug.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(itss);
42 /************************************************************************/
44 typedef struct _ITSS_IStorageImpl
46 IStorage IStorage_iface;
47 LONG ref;
48 struct chmFile *chmfile;
49 WCHAR dir[1];
50 } ITSS_IStorageImpl;
52 struct enum_info
54 struct enum_info *next, *prev;
55 struct chmUnitInfo ui;
58 typedef struct _IEnumSTATSTG_Impl
60 IEnumSTATSTG IEnumSTATSTG_iface;
61 LONG ref;
62 struct enum_info *first, *last, *current;
63 } IEnumSTATSTG_Impl;
65 typedef struct _IStream_Impl
67 IStream IStream_iface;
68 LONG ref;
69 ITSS_IStorageImpl *stg;
70 ULONGLONG addr;
71 struct chmUnitInfo ui;
72 } IStream_Impl;
74 static inline ITSS_IStorageImpl *impl_from_IStorage(IStorage *iface)
76 return CONTAINING_RECORD(iface, ITSS_IStorageImpl, IStorage_iface);
79 static inline IEnumSTATSTG_Impl *impl_from_IEnumSTATSTG(IEnumSTATSTG *iface)
81 return CONTAINING_RECORD(iface, IEnumSTATSTG_Impl, IEnumSTATSTG_iface);
84 static inline IStream_Impl *impl_from_IStream(IStream *iface)
86 return CONTAINING_RECORD(iface, IStream_Impl, IStream_iface);
89 static HRESULT ITSS_create_chm_storage(
90 struct chmFile *chmfile, const WCHAR *dir, IStorage** ppstgOpen );
91 static IStream_Impl* ITSS_create_stream(
92 ITSS_IStorageImpl *stg, struct chmUnitInfo *ui );
94 /************************************************************************/
96 static HRESULT WINAPI ITSS_IEnumSTATSTG_QueryInterface(
97 IEnumSTATSTG* iface,
98 REFIID riid,
99 void** ppvObject)
101 IEnumSTATSTG_Impl *This = impl_from_IEnumSTATSTG(iface);
103 if (IsEqualGUID(riid, &IID_IUnknown)
104 || IsEqualGUID(riid, &IID_IEnumSTATSTG))
106 IEnumSTATSTG_AddRef(iface);
107 *ppvObject = &This->IEnumSTATSTG_iface;
108 return S_OK;
111 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
112 return E_NOINTERFACE;
115 static ULONG WINAPI ITSS_IEnumSTATSTG_AddRef(
116 IEnumSTATSTG* iface)
118 IEnumSTATSTG_Impl *This = impl_from_IEnumSTATSTG(iface);
119 return InterlockedIncrement(&This->ref);
122 static ULONG WINAPI ITSS_IEnumSTATSTG_Release(
123 IEnumSTATSTG* iface)
125 IEnumSTATSTG_Impl *This = impl_from_IEnumSTATSTG(iface);
127 ULONG ref = InterlockedDecrement(&This->ref);
129 if (ref == 0)
131 while( This->first )
133 struct enum_info *t = This->first->next;
134 HeapFree( GetProcessHeap(), 0, This->first );
135 This->first = t;
137 HeapFree(GetProcessHeap(), 0, This);
138 ITSS_UnlockModule();
141 return ref;
144 static HRESULT WINAPI ITSS_IEnumSTATSTG_Next(
145 IEnumSTATSTG* iface,
146 ULONG celt,
147 STATSTG* rgelt,
148 ULONG* pceltFetched)
150 IEnumSTATSTG_Impl *This = impl_from_IEnumSTATSTG(iface);
151 DWORD len, n;
152 struct enum_info *cur;
154 TRACE("%p %u %p %p\n", This, celt, rgelt, pceltFetched );
156 cur = This->current;
157 n = 0;
158 while( (n<celt) && cur)
160 WCHAR *str;
162 memset( rgelt, 0, sizeof *rgelt );
164 /* copy the name */
165 str = cur->ui.path;
166 if( *str == '/' )
167 str++;
168 len = lstrlenW( str ) + 1;
169 rgelt->pwcsName = CoTaskMemAlloc( len*sizeof(WCHAR) );
170 lstrcpyW( rgelt->pwcsName, str );
172 /* determine the type */
173 if( rgelt->pwcsName[len-2] == '/' )
175 rgelt->pwcsName[len-2] = 0;
176 rgelt->type = STGTY_STORAGE;
178 else
179 rgelt->type = STGTY_STREAM;
181 /* copy the size */
182 rgelt->cbSize.QuadPart = cur->ui.length;
184 /* advance to the next item if it exists */
185 n++;
186 cur = cur->next;
189 This->current = cur;
190 *pceltFetched = n;
192 if( n < celt )
193 return S_FALSE;
195 return S_OK;
198 static HRESULT WINAPI ITSS_IEnumSTATSTG_Skip(
199 IEnumSTATSTG* iface,
200 ULONG celt)
202 IEnumSTATSTG_Impl *This = impl_from_IEnumSTATSTG(iface);
203 DWORD n;
204 struct enum_info *cur;
206 TRACE("%p %u\n", This, celt );
208 cur = This->current;
209 n = 0;
210 while( (n<celt) && cur)
212 n++;
213 cur = cur->next;
215 This->current = cur;
217 if( n < celt )
218 return S_FALSE;
220 return S_OK;
223 static HRESULT WINAPI ITSS_IEnumSTATSTG_Reset(
224 IEnumSTATSTG* iface)
226 IEnumSTATSTG_Impl *This = impl_from_IEnumSTATSTG(iface);
228 TRACE("%p\n", This );
230 This->current = This->first;
232 return S_OK;
235 static HRESULT WINAPI ITSS_IEnumSTATSTG_Clone(
236 IEnumSTATSTG* iface,
237 IEnumSTATSTG** ppenum)
239 FIXME("\n");
240 return E_NOTIMPL;
243 static const IEnumSTATSTGVtbl IEnumSTATSTG_vtbl =
245 ITSS_IEnumSTATSTG_QueryInterface,
246 ITSS_IEnumSTATSTG_AddRef,
247 ITSS_IEnumSTATSTG_Release,
248 ITSS_IEnumSTATSTG_Next,
249 ITSS_IEnumSTATSTG_Skip,
250 ITSS_IEnumSTATSTG_Reset,
251 ITSS_IEnumSTATSTG_Clone
254 static IEnumSTATSTG_Impl *ITSS_create_enum( void )
256 IEnumSTATSTG_Impl *stgenum;
258 stgenum = HeapAlloc( GetProcessHeap(), 0, sizeof (IEnumSTATSTG_Impl) );
259 stgenum->IEnumSTATSTG_iface.lpVtbl = &IEnumSTATSTG_vtbl;
260 stgenum->ref = 1;
261 stgenum->first = NULL;
262 stgenum->last = NULL;
263 stgenum->current = NULL;
265 ITSS_LockModule();
266 TRACE(" -> %p\n", stgenum );
268 return stgenum;
271 /************************************************************************/
273 static HRESULT WINAPI ITSS_IStorageImpl_QueryInterface(
274 IStorage* iface,
275 REFIID riid,
276 void** ppvObject)
278 ITSS_IStorageImpl *This = impl_from_IStorage(iface);
280 if (IsEqualGUID(riid, &IID_IUnknown)
281 || IsEqualGUID(riid, &IID_IStorage))
283 IStorage_AddRef(iface);
284 *ppvObject = &This->IStorage_iface;
285 return S_OK;
288 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
289 return E_NOINTERFACE;
292 static ULONG WINAPI ITSS_IStorageImpl_AddRef(
293 IStorage* iface)
295 ITSS_IStorageImpl *This = impl_from_IStorage(iface);
296 return InterlockedIncrement(&This->ref);
299 static ULONG WINAPI ITSS_IStorageImpl_Release(
300 IStorage* iface)
302 ITSS_IStorageImpl *This = impl_from_IStorage(iface);
304 ULONG ref = InterlockedDecrement(&This->ref);
306 if (ref == 0)
308 chm_close(This->chmfile);
309 HeapFree(GetProcessHeap(), 0, This);
310 ITSS_UnlockModule();
313 return ref;
316 static HRESULT WINAPI ITSS_IStorageImpl_CreateStream(
317 IStorage* iface,
318 LPCOLESTR pwcsName,
319 DWORD grfMode,
320 DWORD reserved1,
321 DWORD reserved2,
322 IStream** ppstm)
324 FIXME("\n");
325 return E_NOTIMPL;
328 static HRESULT WINAPI ITSS_IStorageImpl_OpenStream(
329 IStorage* iface,
330 LPCOLESTR pwcsName,
331 void* reserved1,
332 DWORD grfMode,
333 DWORD reserved2,
334 IStream** ppstm)
336 ITSS_IStorageImpl *This = impl_from_IStorage(iface);
337 IStream_Impl *stm;
338 DWORD len;
339 struct chmUnitInfo ui;
340 int r;
341 WCHAR *path, *p;
343 TRACE("%p %s %p %u %u %p\n", This, debugstr_w(pwcsName),
344 reserved1, grfMode, reserved2, ppstm );
346 len = lstrlenW( This->dir ) + lstrlenW( pwcsName ) + 1;
347 path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
348 lstrcpyW( path, This->dir );
350 if( pwcsName[0] == '/' || pwcsName[0] == '\\' )
352 p = &path[lstrlenW( path ) - 1];
353 while( ( path <= p ) && ( *p == '/' ) )
354 *p-- = 0;
356 lstrcatW( path, pwcsName );
358 for(p=path; *p; p++) {
359 if(*p == '\\')
360 *p = '/';
363 if(*--p == '/')
364 *p = 0;
366 TRACE("Resolving %s\n", debugstr_w(path));
368 r = chm_resolve_object(This->chmfile, path, &ui);
369 HeapFree( GetProcessHeap(), 0, path );
371 if( r != CHM_RESOLVE_SUCCESS ) {
372 WARN("Could not resolve object\n");
373 return STG_E_FILENOTFOUND;
376 stm = ITSS_create_stream( This, &ui );
377 if( !stm )
378 return E_FAIL;
380 *ppstm = &stm->IStream_iface;
382 return S_OK;
385 static HRESULT WINAPI ITSS_IStorageImpl_CreateStorage(
386 IStorage* iface,
387 LPCOLESTR pwcsName,
388 DWORD grfMode,
389 DWORD dwStgFmt,
390 DWORD reserved2,
391 IStorage** ppstg)
393 FIXME("\n");
394 return E_NOTIMPL;
397 static HRESULT WINAPI ITSS_IStorageImpl_OpenStorage(
398 IStorage* iface,
399 LPCOLESTR pwcsName,
400 IStorage* pstgPriority,
401 DWORD grfMode,
402 SNB snbExclude,
403 DWORD reserved,
404 IStorage** ppstg)
406 ITSS_IStorageImpl *This = impl_from_IStorage(iface);
407 struct chmFile *chmfile;
408 WCHAR *path, *p;
409 DWORD len;
411 TRACE("%p %s %p %u %p %u %p\n", This, debugstr_w(pwcsName),
412 pstgPriority, grfMode, snbExclude, reserved, ppstg);
414 chmfile = chm_dup( This->chmfile );
415 if( !chmfile )
416 return E_FAIL;
418 len = lstrlenW( This->dir ) + lstrlenW( pwcsName ) + 2; /* need room for a terminating slash */
419 path = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) );
420 lstrcpyW( path, This->dir );
422 if( pwcsName[0] == '/' || pwcsName[0] == '\\' )
424 p = &path[lstrlenW( path ) - 1];
425 while( ( path <= p ) && ( *p == '/' ) )
426 *p-- = 0;
428 lstrcatW( path, pwcsName );
430 for(p=path; *p; p++) {
431 if(*p == '\\')
432 *p = '/';
435 /* add a terminating slash if one does not already exist */
436 if(*(p-1) != '/')
438 *p++ = '/';
439 *p = 0;
442 TRACE("Resolving %s\n", debugstr_w(path));
444 return ITSS_create_chm_storage(chmfile, path, ppstg);
447 static HRESULT WINAPI ITSS_IStorageImpl_CopyTo(
448 IStorage* iface,
449 DWORD ciidExclude,
450 const IID* rgiidExclude,
451 SNB snbExclude,
452 IStorage* pstgDest)
454 FIXME("\n");
455 return E_NOTIMPL;
458 static HRESULT WINAPI ITSS_IStorageImpl_MoveElementTo(
459 IStorage* iface,
460 LPCOLESTR pwcsName,
461 IStorage* pstgDest,
462 LPCOLESTR pwcsNewName,
463 DWORD grfFlags)
465 FIXME("\n");
466 return E_NOTIMPL;
469 static HRESULT WINAPI ITSS_IStorageImpl_Commit(
470 IStorage* iface,
471 DWORD grfCommitFlags)
473 FIXME("\n");
474 return E_NOTIMPL;
477 static HRESULT WINAPI ITSS_IStorageImpl_Revert(
478 IStorage* iface)
480 FIXME("\n");
481 return E_NOTIMPL;
484 static int ITSS_chm_enumerator(
485 struct chmFile *h,
486 struct chmUnitInfo *ui,
487 void *context)
489 struct enum_info *info;
490 IEnumSTATSTG_Impl* stgenum = context;
492 TRACE("adding %s to enumeration\n", debugstr_w(ui->path) );
494 info = HeapAlloc( GetProcessHeap(), 0, sizeof (struct enum_info) );
495 info->ui = *ui;
497 info->next = NULL;
498 info->prev = stgenum->last;
499 if( stgenum->last )
500 stgenum->last->next = info;
501 else
502 stgenum->first = info;
503 stgenum->last = info;
505 return CHM_ENUMERATOR_CONTINUE;
508 static HRESULT WINAPI ITSS_IStorageImpl_EnumElements(
509 IStorage* iface,
510 DWORD reserved1,
511 void* reserved2,
512 DWORD reserved3,
513 IEnumSTATSTG** ppenum)
515 ITSS_IStorageImpl *This = impl_from_IStorage(iface);
516 IEnumSTATSTG_Impl* stgenum;
518 TRACE("%p %d %p %d %p\n", This, reserved1, reserved2, reserved3, ppenum );
520 stgenum = ITSS_create_enum();
521 if( !stgenum )
522 return E_FAIL;
524 chm_enumerate_dir(This->chmfile,
525 This->dir,
526 CHM_ENUMERATE_ALL,
527 ITSS_chm_enumerator,
528 stgenum );
530 stgenum->current = stgenum->first;
532 *ppenum = &stgenum->IEnumSTATSTG_iface;
534 return S_OK;
537 static HRESULT WINAPI ITSS_IStorageImpl_DestroyElement(
538 IStorage* iface,
539 LPCOLESTR pwcsName)
541 FIXME("\n");
542 return E_NOTIMPL;
545 static HRESULT WINAPI ITSS_IStorageImpl_RenameElement(
546 IStorage* iface,
547 LPCOLESTR pwcsOldName,
548 LPCOLESTR pwcsNewName)
550 FIXME("\n");
551 return E_NOTIMPL;
554 static HRESULT WINAPI ITSS_IStorageImpl_SetElementTimes(
555 IStorage* iface,
556 LPCOLESTR pwcsName,
557 const FILETIME* pctime,
558 const FILETIME* patime,
559 const FILETIME* pmtime)
561 FIXME("\n");
562 return E_NOTIMPL;
565 static HRESULT WINAPI ITSS_IStorageImpl_SetClass(
566 IStorage* iface,
567 REFCLSID clsid)
569 FIXME("\n");
570 return E_NOTIMPL;
573 static HRESULT WINAPI ITSS_IStorageImpl_SetStateBits(
574 IStorage* iface,
575 DWORD grfStateBits,
576 DWORD grfMask)
578 FIXME("\n");
579 return E_NOTIMPL;
582 static HRESULT WINAPI ITSS_IStorageImpl_Stat(
583 IStorage* iface,
584 STATSTG* pstatstg,
585 DWORD grfStatFlag)
587 FIXME("\n");
588 return E_NOTIMPL;
591 static const IStorageVtbl ITSS_IStorageImpl_Vtbl =
593 ITSS_IStorageImpl_QueryInterface,
594 ITSS_IStorageImpl_AddRef,
595 ITSS_IStorageImpl_Release,
596 ITSS_IStorageImpl_CreateStream,
597 ITSS_IStorageImpl_OpenStream,
598 ITSS_IStorageImpl_CreateStorage,
599 ITSS_IStorageImpl_OpenStorage,
600 ITSS_IStorageImpl_CopyTo,
601 ITSS_IStorageImpl_MoveElementTo,
602 ITSS_IStorageImpl_Commit,
603 ITSS_IStorageImpl_Revert,
604 ITSS_IStorageImpl_EnumElements,
605 ITSS_IStorageImpl_DestroyElement,
606 ITSS_IStorageImpl_RenameElement,
607 ITSS_IStorageImpl_SetElementTimes,
608 ITSS_IStorageImpl_SetClass,
609 ITSS_IStorageImpl_SetStateBits,
610 ITSS_IStorageImpl_Stat,
613 static HRESULT ITSS_create_chm_storage(
614 struct chmFile *chmfile, const WCHAR *dir, IStorage** ppstgOpen )
616 ITSS_IStorageImpl *stg;
618 TRACE("%p %s\n", chmfile, debugstr_w( dir ) );
620 stg = HeapAlloc( GetProcessHeap(), 0,
621 FIELD_OFFSET( ITSS_IStorageImpl, dir[lstrlenW( dir ) + 1] ));
622 stg->IStorage_iface.lpVtbl = &ITSS_IStorageImpl_Vtbl;
623 stg->ref = 1;
624 stg->chmfile = chmfile;
625 lstrcpyW( stg->dir, dir );
627 *ppstgOpen = &stg->IStorage_iface;
629 ITSS_LockModule();
630 return S_OK;
633 HRESULT ITSS_StgOpenStorage(
634 const WCHAR* pwcsName,
635 IStorage* pstgPriority,
636 DWORD grfMode,
637 SNB snbExclude,
638 DWORD reserved,
639 IStorage** ppstgOpen)
641 struct chmFile *chmfile;
643 TRACE("%s\n", debugstr_w(pwcsName) );
645 chmfile = chm_openW( pwcsName );
646 if( !chmfile )
647 return E_FAIL;
649 return ITSS_create_chm_storage( chmfile, L"/", ppstgOpen );
652 /************************************************************************/
654 static HRESULT WINAPI ITSS_IStream_QueryInterface(
655 IStream* iface,
656 REFIID riid,
657 void** ppvObject)
659 IStream_Impl *This = impl_from_IStream(iface);
661 if (IsEqualGUID(riid, &IID_IUnknown)
662 || IsEqualGUID(riid, &IID_ISequentialStream)
663 || IsEqualGUID(riid, &IID_IStream))
665 IStream_AddRef(iface);
666 *ppvObject = &This->IStream_iface;
667 return S_OK;
670 WARN("(%p)->(%s,%p),not found\n",This,debugstr_guid(riid),ppvObject);
671 return E_NOINTERFACE;
674 static ULONG WINAPI ITSS_IStream_AddRef(
675 IStream* iface)
677 IStream_Impl *This = impl_from_IStream(iface);
678 return InterlockedIncrement(&This->ref);
681 static ULONG WINAPI ITSS_IStream_Release(
682 IStream* iface)
684 IStream_Impl *This = impl_from_IStream(iface);
686 ULONG ref = InterlockedDecrement(&This->ref);
688 if (ref == 0)
690 IStorage_Release( &This->stg->IStorage_iface );
691 HeapFree(GetProcessHeap(), 0, This);
692 ITSS_UnlockModule();
695 return ref;
698 static HRESULT WINAPI ITSS_IStream_Read(
699 IStream* iface,
700 void* pv,
701 ULONG cb,
702 ULONG* pcbRead)
704 IStream_Impl *This = impl_from_IStream(iface);
705 ULONG count;
707 TRACE("%p %p %u %p\n", This, pv, cb, pcbRead);
709 count = chm_retrieve_object(This->stg->chmfile,
710 &This->ui, pv, This->addr, cb);
711 This->addr += count;
712 if( pcbRead )
713 *pcbRead = count;
715 return count ? S_OK : S_FALSE;
718 static HRESULT WINAPI ITSS_IStream_Write(
719 IStream* iface,
720 const void* pv,
721 ULONG cb,
722 ULONG* pcbWritten)
724 FIXME("\n");
725 return E_NOTIMPL;
728 static HRESULT WINAPI ITSS_IStream_Seek(
729 IStream* iface,
730 LARGE_INTEGER dlibMove,
731 DWORD dwOrigin,
732 ULARGE_INTEGER* plibNewPosition)
734 IStream_Impl *This = impl_from_IStream(iface);
735 LONGLONG newpos;
737 TRACE("%p %s %u %p\n", This,
738 wine_dbgstr_longlong( dlibMove.QuadPart ), dwOrigin, plibNewPosition );
740 newpos = This->addr;
741 switch( dwOrigin )
743 case STREAM_SEEK_CUR:
744 newpos = This->addr + dlibMove.QuadPart;
745 break;
746 case STREAM_SEEK_SET:
747 newpos = dlibMove.QuadPart;
748 break;
749 case STREAM_SEEK_END:
750 newpos = This->ui.length + dlibMove.QuadPart;
751 break;
754 if( ( newpos < 0 ) || ( newpos > This->ui.length ) )
755 return STG_E_INVALIDPOINTER;
757 This->addr = newpos;
758 if( plibNewPosition )
759 plibNewPosition->QuadPart = This->addr;
761 return S_OK;
764 static HRESULT WINAPI ITSS_IStream_SetSize(
765 IStream* iface,
766 ULARGE_INTEGER libNewSize)
768 FIXME("\n");
769 return E_NOTIMPL;
772 static HRESULT WINAPI ITSS_IStream_CopyTo(
773 IStream* iface,
774 IStream* pstm,
775 ULARGE_INTEGER cb,
776 ULARGE_INTEGER* pcbRead,
777 ULARGE_INTEGER* pcbWritten)
779 FIXME("\n");
780 return E_NOTIMPL;
783 static HRESULT WINAPI ITSS_IStream_Commit(
784 IStream* iface,
785 DWORD grfCommitFlags)
787 FIXME("\n");
788 return E_NOTIMPL;
791 static HRESULT WINAPI ITSS_IStream_Revert(
792 IStream* iface)
794 FIXME("\n");
795 return E_NOTIMPL;
798 static HRESULT WINAPI ITSS_IStream_LockRegion(
799 IStream* iface,
800 ULARGE_INTEGER libOffset,
801 ULARGE_INTEGER cb,
802 DWORD dwLockType)
804 FIXME("\n");
805 return E_NOTIMPL;
808 static HRESULT WINAPI ITSS_IStream_UnlockRegion(
809 IStream* iface,
810 ULARGE_INTEGER libOffset,
811 ULARGE_INTEGER cb,
812 DWORD dwLockType)
814 FIXME("\n");
815 return E_NOTIMPL;
818 static HRESULT WINAPI ITSS_IStream_Stat(
819 IStream* iface,
820 STATSTG* pstatstg,
821 DWORD grfStatFlag)
823 IStream_Impl *This = impl_from_IStream(iface);
825 TRACE("%p %p %d\n", This, pstatstg, grfStatFlag);
827 memset( pstatstg, 0, sizeof *pstatstg );
828 if( !( grfStatFlag & STATFLAG_NONAME ) )
830 FIXME("copy the name\n");
832 pstatstg->type = STGTY_STREAM;
833 pstatstg->cbSize.QuadPart = This->ui.length;
834 pstatstg->grfMode = STGM_READ;
835 pstatstg->clsid = CLSID_ITStorage;
837 return S_OK;
840 static HRESULT WINAPI ITSS_IStream_Clone(
841 IStream* iface,
842 IStream** ppstm)
844 FIXME("\n");
845 return E_NOTIMPL;
848 static const IStreamVtbl ITSS_IStream_vtbl =
850 ITSS_IStream_QueryInterface,
851 ITSS_IStream_AddRef,
852 ITSS_IStream_Release,
853 ITSS_IStream_Read,
854 ITSS_IStream_Write,
855 ITSS_IStream_Seek,
856 ITSS_IStream_SetSize,
857 ITSS_IStream_CopyTo,
858 ITSS_IStream_Commit,
859 ITSS_IStream_Revert,
860 ITSS_IStream_LockRegion,
861 ITSS_IStream_UnlockRegion,
862 ITSS_IStream_Stat,
863 ITSS_IStream_Clone,
866 static IStream_Impl *ITSS_create_stream(
867 ITSS_IStorageImpl *stg, struct chmUnitInfo *ui )
869 IStream_Impl *stm;
871 stm = HeapAlloc( GetProcessHeap(), 0, sizeof (IStream_Impl) );
872 stm->IStream_iface.lpVtbl = &ITSS_IStream_vtbl;
873 stm->ref = 1;
874 stm->addr = 0;
875 stm->ui = *ui;
876 stm->stg = stg;
877 IStorage_AddRef( &stg->IStorage_iface );
879 ITSS_LockModule();
881 TRACE(" -> %p\n", stm );
883 return stm;