Changeset 7926 for trunk/src/ole32/storage32.c
- Timestamp:
- Feb 15, 2002, 6:18:52 PM (24 years ago)
- File:
-
- 1 edited
-
trunk/src/ole32/storage32.c (modified) (46 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ole32/storage32.c
r7508 r7926 10 10 * Copyright 1999 Thuy Nguyen 11 11 */ 12 13 12 #ifdef __WIN32OS2__ 14 13 #include <odin.h> … … 36 35 37 36 #define FILE_BEGIN 0 38 39 37 40 38 … … 167 165 StorageBaseImpl_SetClass, 168 166 StorageImpl_SetStateBits, 169 Storage BaseImpl_Stat167 StorageImpl_Stat 170 168 }; 171 169 … … 343 341 StgProperty currentProperty; 344 342 ULONG foundPropertyIndex; 343 HRESULT res = STG_E_UNKNOWN; 345 344 346 345 TRACE("(%p, %s, %p, %lx, %ld, %p)\n", … … 351 350 */ 352 351 if ( (pwcsName==NULL) || (ppstm==0) ) 353 return E_INVALIDARG; 352 { 353 res = E_INVALIDARG; 354 goto end; 355 } 354 356 355 357 /* 356 358 * Initialize the out parameter 357 359 */ 358 *ppstm = 0;360 *ppstm = NULL; 359 361 360 362 /* … … 362 364 */ 363 365 if ( FAILED( validateSTGM(grfMode) )) 364 return STG_E_INVALIDFLAG; 366 { 367 res = STG_E_INVALIDFLAG; 368 goto end; 369 } 365 370 366 371 /* … … 370 375 (grfMode & STGM_DELETEONRELEASE) || 371 376 (grfMode & STGM_TRANSACTED) ) 372 return STG_E_INVALIDFUNCTION; 377 { 378 res = STG_E_INVALIDFUNCTION; 379 goto end; 380 } 373 381 374 382 /* … … 411 419 StgStreamImpl_AddRef(*ppstm); 412 420 413 return S_OK; 421 res = S_OK; 422 goto end; 414 423 } 415 424 416 return E_OUTOFMEMORY; 417 } 418 419 return STG_E_FILENOTFOUND; 425 res = E_OUTOFMEMORY; 426 goto end; 427 } 428 429 res = STG_E_FILENOTFOUND; 430 431 end: 432 if (res == S_OK) 433 TRACE("<-- IStream %p\n", *ppstm); 434 TRACE("<-- %08lx\n", res); 435 return res; 420 436 } 421 437 … … 441 457 StgProperty currentProperty; 442 458 ULONG foundPropertyIndex; 459 HRESULT res = STG_E_UNKNOWN; 443 460 444 461 TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n", … … 450 467 */ 451 468 if ( (This==0) || (pwcsName==NULL) || (ppstg==0) ) 452 return E_INVALIDARG; 469 { 470 res = E_INVALIDARG; 471 goto end; 472 } 473 474 /* as documented */ 475 if (snbExclude != NULL) 476 { 477 res = STG_E_INVALIDPARAMETER; 478 goto end; 479 } 453 480 454 481 /* … … 456 483 */ 457 484 if ( FAILED( validateSTGM(grfMode) )) 458 return STG_E_INVALIDFLAG; 485 { 486 res = STG_E_INVALIDFLAG; 487 goto end; 488 } 459 489 460 490 /* … … 464 494 (grfMode & STGM_DELETEONRELEASE) || 465 495 (grfMode & STGM_PRIORITY) ) 466 return STG_E_INVALIDFUNCTION; 496 { 497 res = STG_E_INVALIDFUNCTION; 498 goto end; 499 } 467 500 468 501 /* 469 502 * Initialize the out parameter 470 503 */ 471 *ppstg = 0;504 *ppstg = NULL; 472 505 473 506 /* … … 514 547 StorageBaseImpl_AddRef(*ppstg); 515 548 516 return S_OK; 549 res = S_OK; 550 goto end; 517 551 } 518 552 519 return STG_E_INSUFFICIENTMEMORY; 520 } 521 522 return STG_E_FILENOTFOUND; 553 res = STG_E_INSUFFICIENTMEMORY; 554 goto end; 555 } 556 557 res = STG_E_FILENOTFOUND; 558 559 end: 560 TRACE("<-- %08lx\n", res); 561 return res; 523 562 } 524 563 … … 587 626 ICOM_THIS(StorageBaseImpl,iface); 588 627 StgProperty curProperty; 589 BOOL readSuccessful; 628 BOOL readSuccessful; 629 HRESULT res = STG_E_UNKNOWN; 590 630 591 631 TRACE("(%p, %p, %lx)\n", … … 596 636 */ 597 637 if ( (This==0) || (pstatstg==0)) 598 return E_INVALIDARG; 638 { 639 res = E_INVALIDARG; 640 goto end; 641 } 599 642 600 643 /* … … 613 656 grfStatFlag); 614 657 615 return S_OK; 616 } 617 618 return E_FAIL; 658 res = S_OK; 659 goto end; 660 } 661 662 res = E_FAIL; 663 664 end: 665 if (res == S_OK) 666 { 667 TRACE("<-- STATSTG: pwcsName: %s, type: %ld, cbSize.Low/High: %ld/%ld, grfMode: %08lx, grfLocksSupported: %ld, grfStateBits: %08lx\n", debugstr_w(pstatstg->pwcsName), pstatstg->type, pstatstg->cbSize.s.LowPart, pstatstg->cbSize.s.HighPart, pstatstg->grfMode, pstatstg->grfLocksSupported, pstatstg->grfStateBits); 668 } 669 TRACE("<-- %08lx\n", res); 670 return res; 619 671 } 620 672 … … 1687 1739 1688 1740 1741 /************************************************************************ 1742 * StorageImpl_Stat (IStorage) 1743 * 1744 * This method will retrieve information about this storage object. 1745 * 1746 * See Windows documentation for more details on IStorage methods. 1747 */ 1748 HRESULT WINAPI StorageImpl_Stat( IStorage* iface, 1749 STATSTG* pstatstg, /* [out] */ 1750 DWORD grfStatFlag) /* [in] */ 1751 { 1752 StorageImpl* const This = (StorageImpl*)iface; 1753 HRESULT result = StorageBaseImpl_Stat( iface, pstatstg, grfStatFlag ); 1754 1755 if ( !FAILED(result) && ((grfStatFlag & STATFLAG_NONAME) == 0) && This->pwcsName ) 1756 { 1757 CoTaskMemFree(pstatstg->pwcsName); 1758 pstatstg->pwcsName = CoTaskMemAlloc((lstrlenW(This->pwcsName)+1)*sizeof(WCHAR)); 1759 strcpyW(pstatstg->pwcsName, This->pwcsName); 1760 } 1761 1762 return result; 1763 } 1764 1765 1766 1689 1767 /********************************************************************* 1690 1768 * … … 2083 2161 const FILETIME *pmtime) /* [in] */ 2084 2162 { 2085 FIXME(" not implemented!\n");2086 return E_NOTIMPL;2163 FIXME("(%s,...), stub!\n",debugstr_w(pwcsName)); 2164 return S_OK; 2087 2165 } 2088 2166 … … 2102 2180 StorageImpl* This, 2103 2181 HANDLE hFile, 2182 LPCOLESTR pwcsName, 2104 2183 ILockBytes* pLkbyt, 2105 2184 DWORD openFlags, … … 2111 2190 BOOL readSuccessful; 2112 2191 ULONG currentPropertyIndex; 2113 2192 2114 2193 if ( FAILED( validateSTGM(openFlags) )) 2115 2194 return STG_E_INVALIDFLAG; … … 2118 2197 2119 2198 /* 2120 * Initialize the virtual f gunction table.2199 * Initialize the virtual function table. 2121 2200 */ 2122 2201 ICOM_VTBL(This) = &Storage32Impl_Vtbl; … … 2124 2203 2125 2204 /* 2126 * This is the top-level storage so initialize the ancest er pointer2205 * This is the top-level storage so initialize the ancestor pointer 2127 2206 * to this. 2128 2207 */ … … 2134 2213 This->hFile = hFile; 2135 2214 2215 /* 2216 * Store copy of file path. 2217 */ 2218 if(pwcsName) { 2219 This->pwcsName = HeapAlloc(GetProcessHeap(), 0, 2220 (lstrlenW(pwcsName)+1)*sizeof(WCHAR)); 2221 if (!This->pwcsName) 2222 return STG_E_INSUFFICIENTMEMORY; 2223 strcpyW(This->pwcsName, pwcsName); 2224 } 2225 2136 2226 /* 2137 2227 * Initialize the big block cache. … … 2251 2341 2252 2342 /* 2253 * Find the ID of the root in the property sets.2343 * Find the ID of the root in the property sets. 2254 2344 */ 2255 2345 currentPropertyIndex = 0; … … 2296 2386 { 2297 2387 TRACE("(%p)\n", This); 2388 2389 if(This->pwcsName) 2390 HeapFree(GetProcessHeap(), 0, This->pwcsName); 2298 2391 2299 2392 BlockChainStream_Destroy(This->smallBlockRootChain); … … 2881 2974 * blocks, just make sure they are what we're expecting. 2882 2975 */ 2883 assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) && 2884 (This->smallBlockSize==DEF_SMALL_BLOCK_SIZE)); 2976 if (This->bigBlockSize != DEF_BIG_BLOCK_SIZE || 2977 This->smallBlockSize != DEF_SMALL_BLOCK_SIZE) 2978 { 2979 WARN("Broken OLE storage file\n"); 2980 hr = STG_E_INVALIDHEADER; 2981 } 2982 else 2983 hr = S_OK; 2885 2984 2886 2985 /* … … 2888 2987 */ 2889 2988 StorageImpl_ReleaseBigBlock(This, headerBigBlock); 2890 2891 hr = S_OK;2892 2989 } 2893 2990 … … 3016 3113 currentProperty, 3017 3114 &bytesRead); 3018 3115 3019 3116 if (readSuccessful) 3020 3117 { 3118 /* replace the name of root entry (often "Root Entry") by the file name */ 3119 WCHAR *propName = (index == This->rootPropertySetIndex) ? 3120 This->filename : (WCHAR *)currentProperty+OFFSET_PS_NAME; 3121 3021 3122 memset(buffer->name, 0, sizeof(buffer->name)); 3022 3123 memcpy( 3023 3124 buffer->name, 3024 currentProperty+OFFSET_PS_NAME,3125 propName, 3025 3126 PROPERTY_NAME_BUFFER_LEN ); 3127 TRACE("storage name: %s\n", debugstr_w(buffer->name)); 3026 3128 3027 3129 memcpy(&buffer->propertyType, currentProperty + OFFSET_PS_PROPERTYTYPE, 1); … … 5368 5470 newStorage, 5369 5471 hFile, 5472 pwcsName, 5370 5473 NULL, 5371 5474 grfMode, … … 5406 5509 DWORD shareMode; 5407 5510 DWORD accessMode; 5511 WCHAR fullname[MAX_PATH]; 5512 WIN32_FILE_ATTRIBUTE_DATA Fad; 5408 5513 5409 5514 TRACE("(%s, %p, %lx, %p, %ld, %p)\n", … … 5415 5520 */ 5416 5521 if (( pwcsName == 0) || (ppstgOpen == 0) ) 5417 return STG_E_INVALIDPOINTER; 5522 { 5523 hr = STG_E_INVALIDPOINTER; 5524 goto end; 5525 } 5418 5526 5419 5527 /* … … 5421 5529 */ 5422 5530 if ( FAILED( validateSTGM(grfMode) )) 5423 return STG_E_INVALIDFLAG; 5531 { 5532 hr = STG_E_INVALIDFLAG; 5533 goto end; 5534 } 5424 5535 5425 5536 /* … … 5445 5556 if (hFile==INVALID_HANDLE_VALUE) 5446 5557 { 5447 HRESULT hr = E_FAIL;5448 5558 DWORD last_error = GetLastError(); 5559 5560 hr = E_FAIL; 5449 5561 5450 5562 switch (last_error) … … 5471 5583 } 5472 5584 5473 return hr;5585 goto end; 5474 5586 } 5475 5587 … … 5480 5592 5481 5593 if (newStorage == 0) 5482 return STG_E_INSUFFICIENTMEMORY; 5483 5594 { 5595 hr = STG_E_INSUFFICIENTMEMORY; 5596 goto end; 5597 } 5598 5599 /* if the file's length was zero, initialize the storage */ 5484 5600 hr = StorageImpl_Construct( 5485 5601 newStorage, 5486 5602 hFile, 5603 pwcsName, 5487 5604 NULL, 5488 5605 grfMode, 5489 5606 TRUE, 5490 FALSE);5607 !(Fad.nFileSizeHigh || Fad.nFileSizeLow) /* FALSE */ ); 5491 5608 5492 5609 if (FAILED(hr)) … … 5497 5614 */ 5498 5615 if(hr == STG_E_INVALIDHEADER) 5499 return STG_E_FILEALREADYEXISTS; 5500 return hr; 5501 } 5502 5616 hr = STG_E_FILEALREADYEXISTS; 5617 goto end; 5618 } 5619 5620 /* prepare the file name string given in lieu of the root property name */ 5621 GetFullPathNameW(pwcsName, MAX_PATH, fullname, NULL); 5622 memcpy(newStorage->filename, fullname, PROPERTY_NAME_BUFFER_LEN); 5623 newStorage->filename[PROPERTY_NAME_BUFFER_LEN-1] = '\0'; 5624 5503 5625 /* 5504 5626 * Get an "out" pointer for the caller. … … 5509 5631 (void**)ppstgOpen); 5510 5632 5633 end: 5634 TRACE("<-- %08lx, IStorage %p\n", hr, ppstgOpen ? *ppstgOpen : NULL); 5511 5635 return hr; 5512 5636 } … … 5541 5665 newStorage, 5542 5666 0, 5667 0, 5543 5668 plkbyt, 5544 5669 grfMode, … … 5605 5730 newStorage, 5606 5731 0, 5732 0, 5607 5733 plkbyt, 5608 5734 grfMode, … … 5629 5755 /****************************************************************************** 5630 5756 * StgSetTimes [ole32.150] 5631 * 5632 * 5633 * /5634 HRESULT WINAPI StgSetTimes(WCHAR * str, FILETIME * a, FILETIME * b, FILETIME *c ) 5635 { 5636 5637 FIXME("(% p, %p, %p, %p),stub!\n", str, a, b, c);5638 return FALSE;5757 * StgSetTimes [OLE32.150] 5758 * 5759 * 5760 */ 5761 HRESULT WINAPI StgSetTimes(OLECHAR *str, FILETIME *a, FILETIME *b, FILETIME *c ) 5762 { 5763 FIXME("(%s, %p, %p, %p),stub!\n", debugstr_w(str), a, b, c); 5764 return S_OK; 5639 5765 } 5640 5766 … … 5677 5803 5678 5804 /*********************************************************************** 5679 * ReadClassStg 5805 * ReadClassStg (OLE32.134) 5680 5806 * 5681 5807 * This method reads the CLSID previously written to a storage object with the WriteClassStg. … … 5702 5828 5703 5829 /*********************************************************************** 5704 * OleLoadFromStream 5830 * OleLoadFromStream (OLE32.113) 5705 5831 * 5706 5832 * This function loads an object from stream … … 5736 5862 5737 5863 /*********************************************************************** 5738 * OleSaveToStream 5864 * OleSaveToStream (OLE32.125) 5739 5865 * 5740 5866 * This function saves an object with the IPersistStream interface on it … … 6948 7074 if(hRes == S_OK) 6949 7075 { 6950 /* Was it originaly Ole10 */7076 /* Was it originally Ole10 */ 6951 7077 hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream); 6952 7078 if(hRes == S_OK) 6953 7079 { 6954 7080 IStream_Release(pStream); 6955 /* Get Presentation Data for Ole10Native */7081 /* Get Presentation Data for Ole10Native */ 6956 7082 OLECONVERT_GetOle10PresData(pstg, pOleStreamData); 6957 7083 } 6958 7084 else 6959 7085 { 6960 /* Get Presentation Data (OLE20)*/7086 /* Get Presentation Data (OLE20) */ 6961 7087 OLECONVERT_GetOle20PresData(pstg, pOleStreamData); 6962 7088 } … … 6992 7118 6993 7119 #ifdef __WIN32OS2__ 7120 6994 7121 static const BYTE STORAGE_notmagic[8]={0x0e,0x11,0xfc,0x0d,0xd0,0xcf,0x11,0xe0}; 6995 7122 6996 7123 /****************************************************************************** 6997 * StgIsStorageFile 16[STORAGE.5]7124 * StgIsStorageFile [STORAGE.5] 6998 7125 */ 6999 7126 HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) { … … 7037 7164 StgIsStorageFile(LPCOLESTR fn) 7038 7165 { 7039 LPOLESTR16 xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn); 7040 HRESULT ret = StgIsStorageFile16(xfn); 7041 7042 HeapFree(GetProcessHeap(),0,xfn); 7043 return ret; 7166 HRESULT ret; 7167 DWORD len = WideCharToMultiByte( CP_ACP, 0, fn, -1, NULL, 0, NULL, NULL ); 7168 LPSTR strA = HeapAlloc( GetProcessHeap(), 0, len ); 7169 7170 WideCharToMultiByte( CP_ACP, 0, fn, -1, strA, len, NULL, NULL ); 7171 ret = StgIsStorageFile16(strA); 7172 HeapFree( GetProcessHeap(), 0, strA ); 7173 return ret; 7044 7174 } 7045 7175 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
