Ignore:
Timestamp:
Feb 15, 2002, 6:18:52 PM (24 years ago)
Author:
sandervl
Message:

Wine 20020215 resync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/ole32/storage32.c

    r7508 r7926  
    1010 * Copyright 1999 Thuy Nguyen
    1111 */
    12 
    1312#ifdef __WIN32OS2__
    1413#include <odin.h>
     
    3635
    3736#define FILE_BEGIN 0
    38 
    3937
    4038
     
    167165    StorageBaseImpl_SetClass,
    168166    StorageImpl_SetStateBits,
    169     StorageBaseImpl_Stat
     167    StorageImpl_Stat
    170168};
    171169
     
    343341  StgProperty       currentProperty;
    344342  ULONG             foundPropertyIndex;
     343  HRESULT           res = STG_E_UNKNOWN;
    345344
    346345  TRACE("(%p, %s, %p, %lx, %ld, %p)\n",
     
    351350   */
    352351  if ( (pwcsName==NULL) || (ppstm==0) )
    353     return E_INVALIDARG;
     352  {
     353    res = E_INVALIDARG;
     354    goto end;
     355  }
    354356 
    355357  /*
    356358   * Initialize the out parameter
    357359   */
    358   *ppstm = 0;
     360  *ppstm = NULL;
    359361 
    360362  /*
     
    362364   */
    363365  if ( FAILED( validateSTGM(grfMode) ))
    364     return STG_E_INVALIDFLAG;
     366  {
     367    res = STG_E_INVALIDFLAG;
     368    goto end;
     369  }
    365370
    366371  /*
     
    370375        (grfMode & STGM_DELETEONRELEASE) ||
    371376        (grfMode & STGM_TRANSACTED) )
    372     return STG_E_INVALIDFUNCTION;
     377  {
     378    res = STG_E_INVALIDFUNCTION;
     379    goto end;
     380  }
    373381
    374382  /*
     
    411419      StgStreamImpl_AddRef(*ppstm);
    412420     
    413       return S_OK;
     421      res = S_OK;
     422      goto end;
    414423    }
    415424   
    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
     431end:
     432  if (res == S_OK)
     433    TRACE("<-- IStream %p\n", *ppstm);
     434  TRACE("<-- %08lx\n", res);
     435  return res;
    420436}
    421437
     
    441457  StgProperty            currentProperty;
    442458  ULONG                  foundPropertyIndex;
     459  HRESULT                res = STG_E_UNKNOWN;
    443460
    444461  TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n",
     
    450467   */
    451468  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  }
    453480 
    454481  /*
     
    456483   */
    457484  if ( FAILED( validateSTGM(grfMode) ))
    458     return STG_E_INVALIDFLAG;
     485  {
     486    res = STG_E_INVALIDFLAG;
     487    goto end;
     488  }
    459489
    460490  /*
     
    464494        (grfMode & STGM_DELETEONRELEASE) ||
    465495        (grfMode & STGM_PRIORITY) )
    466     return STG_E_INVALIDFUNCTION;
     496  {
     497    res = STG_E_INVALIDFUNCTION;
     498    goto end;
     499  }
    467500
    468501  /*
    469502   * Initialize the out parameter
    470503   */
    471   *ppstg = 0;
     504  *ppstg = NULL;
    472505 
    473506  /*
     
    514547      StorageBaseImpl_AddRef(*ppstg);
    515548     
    516       return S_OK;
     549      res = S_OK;
     550      goto end;
    517551    }
    518552   
    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
     559end:
     560  TRACE("<-- %08lx\n", res);
     561  return res;
    523562}
    524563
     
    587626  ICOM_THIS(StorageBaseImpl,iface);
    588627  StgProperty    curProperty;
    589   BOOL         readSuccessful;
     628  BOOL           readSuccessful;
     629  HRESULT        res = STG_E_UNKNOWN;
    590630
    591631  TRACE("(%p, %p, %lx)\n",
     
    596636   */
    597637  if ( (This==0) || (pstatstg==0))
    598     return E_INVALIDARG;
     638  {
     639    res = E_INVALIDARG;
     640    goto end;
     641  }
    599642
    600643  /*
     
    613656      grfStatFlag);
    614657   
    615     return S_OK;
    616   }
    617  
    618   return E_FAIL;
     658    res = S_OK;
     659    goto end;
     660  }
     661 
     662  res = E_FAIL;
     663
     664end:
     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;
    619671}
    620672
     
    16871739
    16881740
     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 */
     1748HRESULT 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
    16891767/*********************************************************************
    16901768 *
     
    20832161  const FILETIME  *pmtime)  /* [in] */
    20842162{
    2085   FIXME("not implemented!\n");
    2086   return E_NOTIMPL;
     2163  FIXME("(%s,...), stub!\n",debugstr_w(pwcsName));
     2164  return S_OK;
    20872165}
    20882166
     
    21022180  StorageImpl* This,
    21032181  HANDLE       hFile,
     2182  LPCOLESTR    pwcsName,
    21042183  ILockBytes*  pLkbyt,
    21052184  DWORD        openFlags,
     
    21112190  BOOL      readSuccessful;
    21122191  ULONG       currentPropertyIndex;
    2113  
     2192
    21142193  if ( FAILED( validateSTGM(openFlags) ))
    21152194    return STG_E_INVALIDFLAG;
     
    21182197 
    21192198  /*
    2120    * Initialize the virtual fgunction table.
     2199   * Initialize the virtual function table.
    21212200   */
    21222201  ICOM_VTBL(This)    = &Storage32Impl_Vtbl;
     
    21242203 
    21252204  /*
    2126    * This is the top-level storage so initialize the ancester pointer
     2205   * This is the top-level storage so initialize the ancestor pointer
    21272206   * to this.
    21282207   */
     
    21342213  This->hFile = hFile;
    21352214 
     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
    21362226  /*
    21372227   * Initialize the big block cache.
     
    22512341
    22522342  /*
    2253    * Find the ID of the root int he property sets.
     2343   * Find the ID of the root in the property sets.
    22542344   */
    22552345  currentPropertyIndex = 0;
     
    22962386{
    22972387  TRACE("(%p)\n", This);
     2388
     2389  if(This->pwcsName)
     2390    HeapFree(GetProcessHeap(), 0, This->pwcsName);
    22982391
    22992392  BlockChainStream_Destroy(This->smallBlockRootChain);
     
    28812974     * blocks, just make sure they are what we're expecting.
    28822975     */
    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;
    28852984   
    28862985    /*
     
    28882987     */
    28892988    StorageImpl_ReleaseBigBlock(This, headerBigBlock);
    2890 
    2891     hr = S_OK;
    28922989  }
    28932990 
     
    30163113                    currentProperty,
    30173114                    &bytesRead);
    3018  
     3115
    30193116  if (readSuccessful)
    30203117  {
     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
    30213122    memset(buffer->name, 0, sizeof(buffer->name));
    30223123    memcpy(
    30233124      buffer->name,
    3024       currentProperty+OFFSET_PS_NAME,
     3125      propName,
    30253126      PROPERTY_NAME_BUFFER_LEN );
     3127    TRACE("storage name: %s\n", debugstr_w(buffer->name));
    30263128
    30273129    memcpy(&buffer->propertyType, currentProperty + OFFSET_PS_PROPERTYTYPE, 1);
     
    53685470         newStorage,
    53695471         hFile,
     5472        pwcsName,
    53705473         NULL,
    53715474         grfMode,
     
    54065509  DWORD          shareMode;
    54075510  DWORD          accessMode;
     5511  WCHAR          fullname[MAX_PATH];
     5512  WIN32_FILE_ATTRIBUTE_DATA Fad;
    54085513
    54095514  TRACE("(%s, %p, %lx, %p, %ld, %p)\n",
     
    54155520   */
    54165521  if (( pwcsName == 0) || (ppstgOpen == 0) )
    5417     return STG_E_INVALIDPOINTER;
     5522  {
     5523    hr = STG_E_INVALIDPOINTER;
     5524    goto end;
     5525  }
    54185526
    54195527  /*
     
    54215529   */
    54225530  if ( FAILED( validateSTGM(grfMode) ))
    5423     return STG_E_INVALIDFLAG;
     5531  {
     5532    hr = STG_E_INVALIDFLAG;
     5533    goto end;
     5534  }
    54245535
    54255536  /*
     
    54455556  if (hFile==INVALID_HANDLE_VALUE)
    54465557  {
    5447     HRESULT hr = E_FAIL;
    54485558    DWORD last_error = GetLastError();
     5559
     5560    hr = E_FAIL;
    54495561
    54505562    switch (last_error)
     
    54715583    }
    54725584
    5473     return hr;
     5585    goto end;
    54745586  }
    54755587
     
    54805592 
    54815593  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 */
    54845600  hr = StorageImpl_Construct(
    54855601         newStorage,
    54865602         hFile,
     5603        pwcsName,
    54875604         NULL,
    54885605         grfMode,
    54895606         TRUE,
    5490          FALSE);
     5607         !(Fad.nFileSizeHigh || Fad.nFileSizeLow) /* FALSE */ );
    54915608 
    54925609  if (FAILED(hr))
     
    54975614     */
    54985615    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
    55035625  /*
    55045626   * Get an "out" pointer for the caller.
     
    55095631         (void**)ppstgOpen);
    55105632 
     5633end:
     5634  TRACE("<-- %08lx, IStorage %p\n", hr, ppstgOpen ? *ppstgOpen : NULL);
    55115635  return hr;
    55125636}
     
    55415665         newStorage,
    55425666         0,
     5667        0,
    55435668         plkbyt,
    55445669         grfMode,
     
    56055730         newStorage,
    56065731         0,
     5732        0,
    56075733         plkbyt,
    56085734         grfMode,
     
    56295755/******************************************************************************
    56305756 *              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 */
     5761HRESULT 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;
    56395765}
    56405766
     
    56775803
    56785804/***********************************************************************
    5679  *    ReadClassStg
     5805 *    ReadClassStg (OLE32.134)
    56805806 *
    56815807 * This method reads the CLSID previously written to a storage object with the WriteClassStg.
     
    57025828
    57035829/***********************************************************************
    5704  *    OleLoadFromStream
     5830 *    OleLoadFromStream (OLE32.113)
    57055831 *
    57065832 * This function loads an object from stream
     
    57365862
    57375863/***********************************************************************
    5738  *    OleSaveToStream
     5864 *    OleSaveToStream (OLE32.125)
    57395865 *
    57405866 * This function saves an object with the IPersistStream interface on it
     
    69487074    if(hRes == S_OK)
    69497075    {
    6950         /*Was it originaly Ole10 */
     7076        /* Was it originally Ole10 */
    69517077        hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);   
    69527078        if(hRes == S_OK)
    69537079        {
    69547080            IStream_Release(pStream);
    6955             /*Get Presentation Data for Ole10Native */
     7081            /* Get Presentation Data for Ole10Native */
    69567082            OLECONVERT_GetOle10PresData(pstg, pOleStreamData);
    69577083        }
    69587084        else
    69597085        {
    6960             /*Get Presentation Data (OLE20)*/
     7086            /* Get Presentation Data (OLE20) */
    69617087            OLECONVERT_GetOle20PresData(pstg, pOleStreamData);
    69627088        }
     
    69927118
    69937119#ifdef __WIN32OS2__
     7120
    69947121static const BYTE STORAGE_notmagic[8]={0x0e,0x11,0xfc,0x0d,0xd0,0xcf,0x11,0xe0};
    69957122
    69967123/******************************************************************************
    6997  * StgIsStorageFile16 [STORAGE.5]
     7124 * StgIsStorageFile [STORAGE.5]
    69987125 */
    69997126HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) {
     
    70377164StgIsStorageFile(LPCOLESTR fn)
    70387165{
    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;
    70447174}
    70457175#endif
Note: See TracChangeset for help on using the changeset viewer.