Ignore:
Timestamp:
Sep 15, 2001, 11:32:00 AM (24 years ago)
Author:
sandervl
Message:

restored old version + wine update

File:
1 edited

Legend:

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

    r6648 r6711  
    1 /* $Id: storage32.c,v 1.3 2001-09-05 13:17:12 bird Exp $ */
    21/*
    32 * Compound Storage (32 bit version)
     
    3837#define FILE_BEGIN 0
    3938
     39#ifdef __WIN32OS2__
     40#undef FIXME
     41#undef TRACE
     42#ifdef DEBUG
     43#define TRACE WriteLog("OLE32: %s", __FUNCTION__); WriteLog
     44#define FIXME WriteLog("FIXME OLE32: %s", __FUNCTION__); WriteLog
     45#else
     46#define TRACE 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     47#define FIXME 1 ? (void)0 : (void)((int (*)(char *, ...)) NULL)
     48#endif
     49#endif
     50
    4051
    4152/* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */
     
    4859/* OLESTREAM memory structure to use for Get and Put Routines */
    4960/* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */
    50 typedef struct
     61typedef struct 
    5162{
    5263    DWORD dwOleID;
     
    8697    DWORD dwExtentX;
    8798    DWORD dwExtentY;
    88     DWORD dwSize;
     99    DWORD dwSize; 
    89100    BYTE *pData;
    90101}OLECONVERT_ISTORAGE_OLEPRES;
     
    111122  INT         typeOfRelation);
    112123
    113 static HRESULT adjustPropertyChain(
     124static HRESULT adjustPropertyChain( 
    114125  StorageImpl *This,
    115126  StgProperty   propertyToDelete,
     
    138149 * Declaration of miscellaneous functions...
    139150 */
    140 static HRESULT validateSTGM(DWORD stgmValue);
     151static HRESULT validateSTGM(DWORD stgmValue); 
    141152
    142153static DWORD GetShareModeFromSTGM(DWORD stgm);
     
    224235 * This method implements the common QueryInterface for all IStorage32
    225236 * implementations contained in this file.
    226  *
     237 * 
    227238 * See Windows documentation for more details on IUnknown methods.
    228239 */
     
    238249  if ( (This==0) || (ppvObject==0) )
    239250    return E_INVALIDARG;
    240 
     251 
    241252  /*
    242253   * Initialize the return parameter.
    243254   */
    244255  *ppvObject = 0;
    245 
     256 
    246257  /*
    247258   * Compare the riid with the interface IDs implemented by this object.
    248259   */
    249   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     260  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    250261  {
    251262    *ppvObject = (IStorage*)This;
    252263  }
    253   else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0)
     264  else if (memcmp(&IID_IStorage, riid, sizeof(IID_IStorage)) == 0) 
    254265  {
    255266    *ppvObject = (IStorage*)This;
    256267  }
    257 
     268 
    258269  /*
    259270   * Check that we obtained an interface.
     
    261272  if ((*ppvObject)==0)
    262273    return E_NOINTERFACE;
    263 
     274 
    264275  /*
    265276   * Query Interface always increases the reference count by one when it is
     
    270281  return S_OK;
    271282}
    272 
     283       
    273284/************************************************************************
    274285 * Storage32BaseImpl_AddRef (IUnknown)
     
    276287 * This method implements the common AddRef for all IStorage32
    277288 * implementations contained in this file.
    278  *
     289 * 
    279290 * See Windows documentation for more details on IUnknown methods.
    280291 */
    281 ULONG WINAPI StorageBaseImpl_AddRef(
     292ULONG WINAPI StorageBaseImpl_AddRef( 
    282293            IStorage* iface)
    283294{
     
    287298  return This->ref;
    288299}
    289 
     300       
    290301/************************************************************************
    291302 * Storage32BaseImpl_Release (IUnknown)
     
    293304 * This method implements the common Release for all IStorage32
    294305 * implementations contained in this file.
    295  *
     306 * 
    296307 * See Windows documentation for more details on IUnknown methods.
    297308 */
    298 ULONG WINAPI StorageBaseImpl_Release(
     309ULONG WINAPI StorageBaseImpl_Release( 
    299310      IStorage* iface)
    300311{
     
    311322  {
    312323    /*
    313      * Since we are using a system of base-classes, we want to call the
    314      * destructor of the appropriate derived class. To do this, we are
     324     * Since we are using a system of base-classes, we want to call the 
     325     * destructor of the appropriate derived class. To do this, we are 
    315326     * using virtual functions to implement the destructor.
    316327     */
     
    319330    return 0;
    320331  }
    321 
     332 
    322333  return This->ref;
    323334}
     
    330341 * See Windows documentation for more details on IStorage methods.
    331342 */
    332 HRESULT WINAPI StorageBaseImpl_OpenStream(
     343HRESULT WINAPI StorageBaseImpl_OpenStream( 
    333344  IStorage*        iface,
    334345  const OLECHAR*   pwcsName,  /* [string][in] */
    335346  void*            reserved1, /* [unique][in] */
    336   DWORD            grfMode,   /* [in]  */
    337   DWORD            reserved2, /* [in]  */
    338   IStream**        ppstm)     /* [out] */
     347  DWORD            grfMode,   /* [in]  */       
     348  DWORD            reserved2, /* [in]  */       
     349  IStream**        ppstm)     /* [out] */       
    339350{
    340351  ICOM_THIS(StorageBaseImpl,iface);
     
    344355  ULONG             foundPropertyIndex;
    345356
    346   TRACE("(%p, %s, %p, %lx, %ld, %p)\n",
    347     iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
     357  TRACE("(%p, %s, %p, %lx, %ld, %p)\n", 
     358        iface, debugstr_w(pwcsName), reserved1, grfMode, reserved2, ppstm);
    348359
    349360  /*
     
    352363  if ( (pwcsName==NULL) || (ppstm==0) )
    353364    return E_INVALIDARG;
    354 
     365 
    355366  /*
    356367   * Initialize the out parameter
    357368   */
    358369  *ppstm = 0;
    359 
     370 
    360371  /*
    361372   * Validate the STGM flags
     
    376387   */
    377388  propertyEnumeration = IEnumSTATSTGImpl_Construct(
    378     This->ancestorStorage,
     389    This->ancestorStorage, 
    379390    This->rootPropertySetIndex);
    380 
     391 
    381392  /*
    382393   * Search the enumeration for the property with the given name
     
    386397    pwcsName,
    387398    &currentProperty);
    388 
     399 
    389400  /*
    390401   * Delete the property enumeration since we don't need it anymore
    391402   */
    392403  IEnumSTATSTGImpl_Destroy(propertyEnumeration);
    393 
     404 
    394405  /*
    395406   * If it was found, construct the stream object and return a pointer to it.
    396407   */
    397   if ( (foundPropertyIndex!=PROPERTY_NULL) &&
     408  if ( (foundPropertyIndex!=PROPERTY_NULL) && 
    398409       (currentProperty.propertyType==PROPTYPE_STREAM) )
    399410  {
    400411    newStream = StgStreamImpl_Construct(This, grfMode, foundPropertyIndex);
    401 
     412   
    402413    if (newStream!=0)
    403414    {
     
    406417
    407418      /*
    408        * Since we are returning a pointer to the interface, we have to
     419       * Since we are returning a pointer to the interface, we have to 
    409420       * nail down the reference.
    410421       */
    411422      StgStreamImpl_AddRef(*ppstm);
    412 
     423     
    413424      return S_OK;
    414425    }
    415 
     426   
    416427    return E_OUTOFMEMORY;
    417428  }
    418 
     429 
    419430  return STG_E_FILENOTFOUND;
    420431}
     
    424435 *
    425436 * This method will open a new storage object from the current storage.
    426  *
     437 * 
    427438 * See Windows documentation for more details on IStorage methods.
    428  */
    429 HRESULT WINAPI StorageBaseImpl_OpenStorage(
     439 */       
     440HRESULT WINAPI StorageBaseImpl_OpenStorage( 
    430441  IStorage*        iface,
    431   const OLECHAR*   pwcsName,      /* [string][unique][in] */
    432   IStorage*        pstgPriority,  /* [unique][in] */
    433   DWORD            grfMode,       /* [in] */
    434   SNB              snbExclude,    /* [unique][in] */
    435   DWORD            reserved,      /* [in] */
    436   IStorage**       ppstg)         /* [out] */
     442  const OLECHAR*   pwcsName,      /* [string][unique][in] */ 
     443  IStorage*        pstgPriority,  /* [unique][in] */         
     444  DWORD            grfMode,       /* [in] */                 
     445  SNB              snbExclude,    /* [unique][in] */         
     446  DWORD            reserved,      /* [in] */                 
     447  IStorage**       ppstg)         /* [out] */                       
    437448{
    438449  ICOM_THIS(StorageBaseImpl,iface);
     
    442453  ULONG                  foundPropertyIndex;
    443454
    444   TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n",
    445     iface, debugstr_w(pwcsName), pstgPriority,
    446     grfMode, snbExclude, reserved, ppstg);
    447 
     455  TRACE("(%p, %s, %p, %lx, %p, %ld, %p)\n", 
     456        iface, debugstr_w(pwcsName), pstgPriority,
     457        grfMode, snbExclude, reserved, ppstg);
     458 
    448459  /*
    449460   * Perform a sanity check on the parameters.
     
    451462  if ( (This==0) || (pwcsName==NULL) || (ppstg==0) )
    452463    return E_INVALIDARG;
    453 
     464 
    454465  /*
    455466   * Validate the STGM flags
     
    461472   * As documented.
    462473   */
    463   if ( !(grfMode & STGM_SHARE_EXCLUSIVE) ||
     474  if ( !(grfMode & STGM_SHARE_EXCLUSIVE) || 
    464475        (grfMode & STGM_DELETEONRELEASE) ||
    465476        (grfMode & STGM_PRIORITY) )
     
    470481   */
    471482  *ppstg = 0;
    472 
     483 
    473484  /*
    474485   * Create a property enumeration to search the properties
    475486   */
    476487  propertyEnumeration = IEnumSTATSTGImpl_Construct(
    477                           This->ancestorStorage,
     488                          This->ancestorStorage, 
    478489                          This->rootPropertySetIndex);
    479 
     490 
    480491  /*
    481492   * Search the enumeration for the property with the given name
     
    485496                         pwcsName,
    486497                         &currentProperty);
    487 
     498 
    488499  /*
    489500   * Delete the property enumeration since we don't need it anymore
    490501   */
    491502  IEnumSTATSTGImpl_Destroy(propertyEnumeration);
    492 
     503 
    493504  /*
    494505   * If it was found, construct the stream object and return a pointer to it.
    495506   */
    496   if ( (foundPropertyIndex!=PROPERTY_NULL) &&
     507  if ( (foundPropertyIndex!=PROPERTY_NULL) && 
    497508       (currentProperty.propertyType==PROPTYPE_STORAGE) )
    498509  {
     
    503514                   This->ancestorStorage,
    504515                   foundPropertyIndex);
    505 
     516   
    506517    if (newStorage != 0)
    507518    {
     
    509520
    510521      /*
    511        * Since we are returning a pointer to the interface,
     522       * Since we are returning a pointer to the interface, 
    512523       * we have to nail down the reference.
    513524       */
    514525      StorageBaseImpl_AddRef(*ppstg);
    515 
     526     
    516527      return S_OK;
    517528    }
    518 
     529   
    519530    return STG_E_INSUFFICIENTMEMORY;
    520531  }
    521 
     532 
    522533  return STG_E_FILENOTFOUND;
    523534}
     
    526537 * Storage32BaseImpl_EnumElements (IStorage)
    527538 *
    528  * This method will create an enumerator object that can be used to
     539 * This method will create an enumerator object that can be used to 
    529540 * retrieve informatino about all the properties in the storage object.
    530  *
     541 * 
    531542 * See Windows documentation for more details on IStorage methods.
    532  */
    533 HRESULT WINAPI StorageBaseImpl_EnumElements(
     543 */       
     544HRESULT WINAPI StorageBaseImpl_EnumElements( 
    534545  IStorage*       iface,
    535   DWORD           reserved1, /* [in] */
    536   void*           reserved2, /* [size_is][unique][in] */
    537   DWORD           reserved3, /* [in] */
    538   IEnumSTATSTG**  ppenum)    /* [out] */
     546  DWORD           reserved1, /* [in] */                 
     547  void*           reserved2, /* [size_is][unique][in] */ 
     548  DWORD           reserved3, /* [in] */                 
     549  IEnumSTATSTG**  ppenum)    /* [out] */                 
    539550{
    540551  ICOM_THIS(StorageBaseImpl,iface);
    541552  IEnumSTATSTGImpl* newEnum;
    542553
    543   TRACE("(%p, %ld, %p, %ld, %p)\n",
    544     iface, reserved1, reserved2, reserved3, ppenum);
     554  TRACE("(%p, %ld, %p, %ld, %p)\n", 
     555        iface, reserved1, reserved2, reserved3, ppenum);
    545556
    546557  /*
     
    549560  if ( (This==0) || (ppenum==0))
    550561    return E_INVALIDARG;
    551 
     562 
    552563  /*
    553564   * Construct the enumerator.
     
    566577     */
    567578    IEnumSTATSTGImpl_AddRef(*ppenum);
    568 
     579   
    569580    return S_OK;
    570581  }
     
    577588 *
    578589 * This method will retrieve information about this storage object.
    579  *
     590 * 
    580591 * See Windows documentation for more details on IStorage methods.
    581  */
    582 HRESULT WINAPI StorageBaseImpl_Stat(
     592 */       
     593HRESULT WINAPI StorageBaseImpl_Stat( 
    583594  IStorage*        iface,
    584   STATSTG*         pstatstg,     /* [out] */
    585   DWORD            grfStatFlag)  /* [in] */
     595  STATSTG*         pstatstg,     /* [out] */ 
     596  DWORD            grfStatFlag)  /* [in] */ 
    586597{
    587598  ICOM_THIS(StorageBaseImpl,iface);
     
    589600  BOOL         readSuccessful;
    590601
    591   TRACE("(%p, %p, %lx)\n",
    592     iface, pstatstg, grfStatFlag);
     602  TRACE("(%p, %p, %lx)\n", 
     603        iface, pstatstg, grfStatFlag);
    593604
    594605  /*
     
    609620  {
    610621    StorageUtl_CopyPropertyToSTATSTG(
    611       pstatstg,
    612       &curProperty,
     622      pstatstg, 
     623      &curProperty, 
    613624      grfStatFlag);
    614 
     625   
    615626    return S_OK;
    616627  }
    617 
     628 
    618629  return E_FAIL;
    619630}
     
    622633 * Storage32BaseImpl_RenameElement (IStorage)
    623634 *
    624  * This method will rename the specified element.
     635 * This method will rename the specified element. 
    625636 *
    626637 * See Windows documentation for more details on IStorage methods.
    627  *
    628  * Implementation notes: The method used to rename consists of creating a clone
    629  *    of the deleted StgProperty object setting it with the new name and to
     638 * 
     639 * Implementation notes: The method used to rename consists of creating a clone 
     640 *    of the deleted StgProperty object setting it with the new name and to 
    630641 *    perform a DestroyElement of the old StgProperty.
    631642 */
     
    640651  ULONG             foundPropertyIndex;
    641652
    642   TRACE("(%p, %s, %s)\n",
    643     iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName));
     653  TRACE("(%p, %s, %s)\n", 
     654        iface, debugstr_w(pwcsOldName), debugstr_w(pwcsNewName));
    644655
    645656  /*
     
    687698     * Setup a new property for the renamed property
    688699     */
    689     renamedProperty.sizeOfNameString =
     700    renamedProperty.sizeOfNameString = 
    690701      ( lstrlenW(pwcsNewName)+1 ) * sizeof(WCHAR);
    691 
     702 
    692703    if (renamedProperty.sizeOfNameString > PROPERTY_NAME_BUFFER_LEN)
    693704      return STG_E_INVALIDNAME;
    694 
     705 
    695706    strcpyW(renamedProperty.name, pwcsNewName);
    696 
     707 
    697708    renamedProperty.propertyType  = currentProperty.propertyType;
    698709    renamedProperty.startingBlock = currentProperty.startingBlock;
    699710    renamedProperty.size.s.LowPart  = currentProperty.size.s.LowPart;
    700711    renamedProperty.size.s.HighPart = currentProperty.size.s.HighPart;
    701 
     712 
    702713    renamedProperty.previousProperty = PROPERTY_NULL;
    703714    renamedProperty.nextProperty     = PROPERTY_NULL;
    704 
     715 
    705716    /*
    706717     * Bring the dirProperty link in case it is a storage and in which
     
    708719     */
    709720    renamedProperty.dirProperty = currentProperty.dirProperty;
    710 
    711     /* call CoFileTime to get the current time
     721 
     722    /* call CoFileTime to get the current time 
    712723    renamedProperty.timeStampS1
    713724    renamedProperty.timeStampD1
    714725    renamedProperty.timeStampS2
    715726    renamedProperty.timeStampD2
    716     renamedProperty.propertyUniqueID
     727    renamedProperty.propertyUniqueID 
    717728    */
    718 
    719     /*
     729 
     730    /* 
    720731     * Obtain a free property in the property chain
    721732     */
    722733    renamedPropertyIndex = getFreeProperty(This->ancestorStorage);
    723 
     734 
    724735    /*
    725736     * Save the new property into the new property spot
    726      */
     737     */ 
    727738    StorageImpl_WriteProperty(
    728739      This->ancestorStorage,
    729       renamedPropertyIndex,
     740      renamedPropertyIndex, 
    730741      &renamedProperty);
    731 
    732     /*
     742 
     743    /* 
    733744     * Find a spot in the property chain for our newly created property.
    734745     */
    735746    updatePropertyChain(
    736747      (StorageImpl*)This,
    737       renamedPropertyIndex,
     748      renamedPropertyIndex, 
    738749      renamedProperty);
    739750
    740751    /*
    741      * At this point the renamed property has been inserted in the tree,
    742      * now, before to Destroy the old property we must zeroed it's dirProperty
    743      * otherwise the DestroyProperty below will zap it all and we do not want
     752     * At this point the renamed property has been inserted in the tree, 
     753     * now, before to Destroy the old property we must zeroed it's dirProperty 
     754     * otherwise the DestroyProperty below will zap it all and we do not want 
    744755     * this to happen.
    745756     * Also, we fake that the old property is a storage so the DestroyProperty
    746757     * will not do a SetSize(0) on the stream data.
    747      *
     758     * 
    748759     * This means that we need to tweek the StgProperty if it is a stream or a
    749760     * non empty storage.
     
    757768    StorageImpl_WriteProperty(
    758769      This->ancestorStorage,
    759       foundPropertyIndex,
     770      foundPropertyIndex, 
    760771      &currentProperty);
    761772
    762     /*
    763      * Invoke Destroy to get rid of the ole property and automatically redo
    764      * the linking of it's previous and next members...
    765      */
    766     StorageImpl_DestroyElement((IStorage*)This->ancestorStorage, pwcsOldName);
     773    /* 
     774     * Invoke Destroy to get rid of the ole property and automatically redo 
     775     * the linking of it's previous and next members... 
     776     */ 
     777    StorageImpl_DestroyElement((IStorage*)This->ancestorStorage, pwcsOldName); 
    767778
    768779  }
     
    781792 * Storage32BaseImpl_CreateStream (IStorage)
    782793 *
    783  * This method will create a stream object within this storage
     794 * This method will create a stream object within this storage 
    784795 *
    785796 * See Windows documentation for more details on IStorage methods.
     
    799810  ULONG             foundPropertyIndex, newPropertyIndex;
    800811
    801   TRACE("(%p, %s, %lx, %ld, %ld, %p)\n",
    802     iface, debugstr_w(pwcsName), grfMode,
    803     reserved1, reserved2, ppstm);
     812  TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 
     813        iface, debugstr_w(pwcsName), grfMode,
     814        reserved1, reserved2, ppstm);
    804815
    805816  /*
     
    846857  {
    847858    /*
    848      * An element with this name already exists
     859     * An element with this name already exists 
    849860     */
    850861    if (grfMode & STGM_CREATE)
    851862    {
    852       IStorage_DestroyElement(iface, pwcsName);
    853     }
    854     else
     863      IStorage_DestroyElement(iface, pwcsName); 
     864    }
     865    else 
    855866      return STG_E_FILEALREADYEXISTS;
    856867  }
    857868
    858   /*
    859    * memset the empty property
     869  /* 
     870   * memset the empty property 
    860871   */
    861872  memset(&newStreamProperty, 0, sizeof(StgProperty));
     
    878889  newStreamProperty.dirProperty      = PROPERTY_NULL;
    879890
    880   /* call CoFileTime to get the current time
     891  /* call CoFileTime to get the current time 
    881892  newStreamProperty.timeStampS1
    882893  newStreamProperty.timeStampD1
     
    888899
    889900  /*
    890    * Get a free property or create a new one
     901   * Get a free property or create a new one 
    891902   */
    892903  newPropertyIndex = getFreeProperty(This->ancestorStorage);
     
    894905  /*
    895906   * Save the new property into the new property spot
    896    */
     907   */ 
    897908  StorageImpl_WriteProperty(
    898909    This->ancestorStorage,
    899     newPropertyIndex,
     910    newPropertyIndex, 
    900911    &newStreamProperty);
    901912
    902   /*
     913  /* 
    903914   * Find a spot in the property chain for our newly created property.
    904915   */
    905916  updatePropertyChain(
    906917    (StorageImpl*)This,
    907     newPropertyIndex,
     918    newPropertyIndex, 
    908919    newStreamProperty);
    909920
    910   /*
     921  /* 
    911922   * Open the stream to return it.
    912923   */
     
    934945 * Storage32BaseImpl_SetClass (IStorage)
    935946 *
    936  * This method will write the specified CLSID in the property of this
     947 * This method will write the specified CLSID in the property of this 
    937948 * storage.
    938949 *
     
    949960
    950961  TRACE("(%p, %p)\n", iface, clsid);
    951 
     962 
    952963  success = StorageImpl_ReadProperty(This->ancestorStorage,
    953964                                       This->rootPropertySetIndex,
     
    970981** Storage32Impl implementation
    971982*/
    972 
     983       
    973984/************************************************************************
    974985 * Storage32Impl_CreateStorage (IStorage)
     
    978989 * See Windows documentation for more details on IStorage methods.
    979990 */
    980 HRESULT WINAPI StorageImpl_CreateStorage(
     991HRESULT WINAPI StorageImpl_CreateStorage( 
    981992  IStorage*      iface,
    982   const OLECHAR  *pwcsName, /* [string][in] */
    983   DWORD            grfMode,   /* [in] */
    984   DWORD            reserved1, /* [in] */
    985   DWORD            reserved2, /* [in] */
    986   IStorage       **ppstg)   /* [out] */
     993  const OLECHAR  *pwcsName, /* [string][in] */ 
     994  DWORD            grfMode,   /* [in] */ 
     995  DWORD            reserved1, /* [in] */ 
     996  DWORD            reserved2, /* [in] */ 
     997  IStorage       **ppstg)   /* [out] */ 
    987998{
    988999  StorageImpl* const This=(StorageImpl*)iface;
     
    9951006  HRESULT          hr;
    9961007
    997   TRACE("(%p, %s, %lx, %ld, %ld, %p)\n",
    998     iface, debugstr_w(pwcsName), grfMode,
    999     reserved1, reserved2, ppstg);
    1000 
     1008  TRACE("(%p, %s, %lx, %ld, %ld, %p)\n", 
     1009        iface, debugstr_w(pwcsName), grfMode,
     1010        reserved1, reserved2, ppstg);
     1011 
    10011012  /*
    10021013   * Validate parameters
     
    10341045  {
    10351046    /*
    1036      * An element with this name already exists
     1047     * An element with this name already exists 
    10371048     */
    10381049    if (grfMode & STGM_CREATE)
    1039       IStorage_DestroyElement(iface, pwcsName);
    1040     else
     1050      IStorage_DestroyElement(iface, pwcsName); 
     1051    else 
    10411052      return STG_E_FILEALREADYEXISTS;
    10421053  }
    10431054
    1044   /*
    1045    * memset the empty property
     1055  /* 
     1056   * memset the empty property 
    10461057   */
    10471058  memset(&newProperty, 0, sizeof(StgProperty));
     
    10631074  newProperty.dirProperty      = PROPERTY_NULL;
    10641075
    1065   /* call CoFileTime to get the current time
     1076  /* call CoFileTime to get the current time 
    10661077  newProperty.timeStampS1
    10671078  newProperty.timeStampD1
     
    10721083  /*  newStorageProperty.propertyUniqueID */
    10731084
    1074   /*
     1085  /* 
    10751086   * Obtain a free property in the property chain
    10761087   */
     
    10791090  /*
    10801091   * Save the new property into the new property spot
    1081    */
     1092   */ 
    10821093  StorageImpl_WriteProperty(
    10831094    This->ancestorStorage,
    1084     newPropertyIndex,
     1095    newPropertyIndex, 
    10851096    &newProperty);
    10861097
    1087   /*
     1098  /* 
    10881099   * Find a spot in the property chain for our newly created property.
    10891100   */
    10901101  updatePropertyChain(
    10911102    This,
    1092     newPropertyIndex,
     1103    newPropertyIndex, 
    10931104    newProperty);
    10941105
    1095   /*
     1106  /* 
    10961107   * Open it to get a pointer to return.
    10971108   */
     
    11101121  }
    11111122
    1112 
     1123 
    11131124  return S_OK;
    11141125}
     
    11411152      if (currentProperty.sizeOfNameString == 0)
    11421153      {
    1143         /*
     1154        /* 
    11441155         * The property existis and is available, we found it.
    11451156         */
     
    11581169  } while (newPropertyIndex == PROPERTY_NULL);
    11591170
    1160   /*
    1161    * grow the property chain
     1171  /* 
     1172   * grow the property chain 
    11621173   */
    11631174  if (! readSuccessful)
     
    11691180    ULONG          blockCount    = 0;
    11701181
    1171     /*
    1172      * obtain the new count of property blocks
     1182    /* 
     1183     * obtain the new count of property blocks 
    11731184     */
    11741185    blockCount = BlockChainStream_GetCount(
    11751186                   storage->ancestorStorage->rootBlockChain)+1;
    11761187
    1177     /*
    1178      * initialize the size used by the property stream
     1188    /* 
     1189     * initialize the size used by the property stream 
    11791190     */
    11801191    newSize.s.HighPart = 0;
    11811192    newSize.s.LowPart  = storage->bigBlockSize * blockCount;
    11821193
    1183     /*
    1184      * add a property block to the property chain
     1194    /* 
     1195     * add a property block to the property chain 
    11851196     */
    11861197    BlockChainStream_SetSize(storage->ancestorStorage->rootBlockChain, newSize);
    11871198
    1188     /*
    1189      * memset the empty property in order to initialize the unused newly
     1199    /* 
     1200     * memset the empty property in order to initialize the unused newly 
    11901201     * created property
    11911202     */
    11921203    memset(&emptyProperty, 0, sizeof(StgProperty));
    11931204
    1194     /*
     1205    /* 
    11951206     * initialize them
    11961207     */
    1197     lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount;
    1198 
     1208    lastProperty = storage->bigBlockSize / PROPSET_BLOCK_SIZE * blockCount; 
     1209   
    11991210    for(
    12001211      propertyIndex = newPropertyIndex;
     
    12041215      StorageImpl_WriteProperty(
    12051216        storage->ancestorStorage,
    1206         propertyIndex,
     1217        propertyIndex, 
    12071218        &emptyProperty);
    12081219    }
     
    12161227 * Internal Method
    12171228 *
    1218  * Case insensitive comparaison of StgProperty.name by first considering
     1229 * Case insensitive comparaison of StgProperty.name by first considering 
    12191230 * their size.
    12201231 *
     
    12291240  LONG diff      = lstrlenW(newProperty) - lstrlenW(currentProperty);
    12301241
    1231   if (diff == 0)
    1232   {
    1233     /*
     1242  if (diff == 0) 
     1243  {
     1244    /* 
    12341245     * We compare the string themselves only when they are of the same lenght
    12351246     */
     
    12371248  }
    12381249
    1239   return diff;
     1250  return diff; 
    12401251}
    12411252
     
    12491260  StorageImpl *storage,
    12501261  ULONG         newPropertyIndex,
    1251   StgProperty   newProperty)
     1262  StgProperty   newProperty) 
    12521263{
    12531264  StgProperty currentProperty;
     
    12621273  if (currentProperty.dirProperty != PROPERTY_NULL)
    12631274  {
    1264     /*
     1275    /* 
    12651276     * The root storage contains some element, therefore, start the research
    12661277     * for the appropriate location.
     
    12751286
    12761287    /*
    1277      * Read
     1288     * Read 
    12781289     */
    12791290    StorageImpl_ReadProperty(storage->ancestorStorage,
     
    12881299    {
    12891300      LONG diff = propertyNameCmp( newProperty.name, currentProperty.name);
    1290 
     1301 
    12911302      if (diff < 0)
    12921303      {
     
    13271338      else
    13281339      {
    1329     /*
    1330     * Trying to insert an item with the same name in the
    1331     * subtree structure.
    1332     */
    1333     assert(FALSE);
     1340        /*
     1341        * Trying to insert an item with the same name in the
     1342        * subtree structure.
     1343        */
     1344        assert(FALSE);
    13341345      }
    13351346
     
    13401351  else
    13411352  {
    1342     /*
     1353    /* 
    13431354     * The root storage is empty, link the new property to it's dir property
    13441355     */
     
    13501361}
    13511362
    1352 
     1363     
    13531364/*************************************************************************
    13541365 * CopyTo (IStorage)
    13551366 */
    1356 HRESULT WINAPI StorageImpl_CopyTo(
     1367HRESULT WINAPI StorageImpl_CopyTo( 
    13571368  IStorage*   iface,
    1358   DWORD       ciidExclude,  /* [in] */
    1359   const IID*  rgiidExclude, /* [size_is][unique][in] */
    1360   SNB         snbExclude,   /* [unique][in] */
    1361   IStorage*   pstgDest)     /* [unique][in] */
     1369  DWORD       ciidExclude,  /* [in] */ 
     1370  const IID*  rgiidExclude, /* [size_is][unique][in] */ 
     1371  SNB         snbExclude,   /* [unique][in] */ 
     1372  IStorage*   pstgDest)     /* [unique][in] */ 
    13621373{
    13631374  IEnumSTATSTG *elements     = 0;
     
    13701381    FIXME("Exclude option not implemented\n");
    13711382
    1372   TRACE("(%p, %ld, %p, %p, %p)\n",
    1373     iface, ciidExclude, rgiidExclude,
    1374     snbExclude, pstgDest);
     1383  TRACE("(%p, %ld, %p, %p, %p)\n", 
     1384        iface, ciidExclude, rgiidExclude,
     1385        snbExclude, pstgDest);
    13751386
    13761387  /*
     
    13801391    return STG_E_INVALIDPOINTER;
    13811392
    1382   /*
     1393  /* 
    13831394   * Enumerate the elements
    13841395   */
     
    13931404  IStorage_Stat( iface, &curElement, STATFLAG_NONAME);
    13941405  IStorage_SetClass( pstgDest, &curElement.clsid );
    1395 
     1406 
    13961407  do
    13971408  {
     
    14131424       */
    14141425      hr = IStorage_OpenStorage( iface, curElement.pwcsName, NULL,
    1415                 STGM_READ|STGM_SHARE_EXCLUSIVE,
    1416                 NULL, 0, &pstgChild );
     1426                                STGM_READ|STGM_SHARE_EXCLUSIVE,
     1427                                NULL, 0, &pstgChild );
    14171428
    14181429      if (hr != S_OK)
     
    14251436      if (pstgChild == pstgDest)
    14261437      {
    1427     IEnumSTATSTG_Release(elements);
    1428 
    1429     return STG_E_ACCESSDENIED;
     1438        IEnumSTATSTG_Release(elements);
     1439
     1440        return STG_E_ACCESSDENIED;
    14301441      }
    1431 
     1442           
    14321443      /*
    14331444       * create a new storage in destination storage
     
    14351446      hr = IStorage_CreateStorage( pstgDest, curElement.pwcsName,
    14361447                                   STGM_FAILIFTHERE|STGM_WRITE|STGM_SHARE_EXCLUSIVE,
    1437                    0, 0,
     1448                                   0, 0,
    14381449                                   &pstgTmp );
    14391450      /*
     
    14461457                                   NULL, 0, &pstgTmp );
    14471458      }
    1448 
     1459       
    14491460      if (hr != S_OK)
    14501461        break;
    14511462
    1452 
     1463       
    14531464      /*
    14541465       * do the copy recursively
     
    14561467      hr = IStorage_CopyTo( pstgChild, ciidExclude, rgiidExclude,
    14571468                               snbExclude, pstgTmp );
    1458 
     1469                               
    14591470      IStorage_Release( pstgTmp );
    14601471      IStorage_Release( pstgChild );
     
    14771488       */
    14781489      hr = IStorage_OpenStream( iface, curElement.pwcsName, NULL,
    1479                 STGM_READ|STGM_SHARE_EXCLUSIVE,
    1480                 0, &pstrChild );
     1490                                STGM_READ|STGM_SHARE_EXCLUSIVE,
     1491                                0, &pstrChild );
    14811492
    14821493      if (hr != S_OK)
     
    14921503       */
    14931504      IStream_SetSize(pstrTmp, strStat.cbSize);
    1494 
     1505     
    14951506      /*
    14961507       * do the copy
     
    14981509      hr = IStream_CopyTo( pstrChild, pstrTmp, strStat.cbSize,
    14991510                           NULL, NULL );
    1500 
     1511                               
    15011512      IStream_Release( pstrTmp );
    15021513      IStream_Release( pstrChild );
     
    15131524   */
    15141525  IEnumSTATSTG_Release(elements);
    1515 
     1526 
    15161527  return hr;
    15171528}
    1518 
     1529       
    15191530/*************************************************************************
    15201531 * MoveElementTo (IStorage)
    15211532 */
    1522 HRESULT WINAPI StorageImpl_MoveElementTo(
     1533HRESULT WINAPI StorageImpl_MoveElementTo( 
    15231534  IStorage*     iface,
    1524   const OLECHAR *pwcsName,   /* [string][in] */
    1525   IStorage      *pstgDest,   /* [unique][in] */
    1526   const OLECHAR *pwcsNewName,/* [string][in] */
    1527   DWORD           grfFlags)    /* [in] */
     1535  const OLECHAR *pwcsName,   /* [string][in] */ 
     1536  IStorage      *pstgDest,   /* [unique][in] */ 
     1537  const OLECHAR *pwcsNewName,/* [string][in] */ 
     1538  DWORD           grfFlags)    /* [in] */ 
    15281539{
    15291540  FIXME("not implemented!\n");
    15301541  return E_NOTIMPL;
    15311542}
    1532 
     1543       
    15331544/*************************************************************************
    15341545 * Commit (IStorage)
    15351546 */
    1536 HRESULT WINAPI StorageImpl_Commit(
     1547HRESULT WINAPI StorageImpl_Commit( 
    15371548  IStorage*   iface,
    1538   DWORD         grfCommitFlags)/* [in] */
     1549  DWORD         grfCommitFlags)/* [in] */ 
    15391550{
    15401551  FIXME("(%ld): stub!\n", grfCommitFlags);
    15411552  return S_OK;
    15421553}
    1543 
     1554       
    15441555/*************************************************************************
    15451556 * Revert (IStorage)
    15461557 */
    1547 HRESULT WINAPI StorageImpl_Revert(
     1558HRESULT WINAPI StorageImpl_Revert( 
    15481559  IStorage* iface)
    15491560{
     
    15551566 * DestroyElement (IStorage)
    15561567 *
    1557  * Stategy: This implementation is build this way for simplicity not for speed.
     1568 * Stategy: This implementation is build this way for simplicity not for speed. 
    15581569 *          I always delete the top most element of the enumeration and adjust
    1559  *          the deleted element pointer all the time.  This takes longer to
    1560  *          do but allow to reinvoke DestroyElement whenever we encounter a
     1570 *          the deleted element pointer all the time.  This takes longer to 
     1571 *          do but allow to reinvoke DestroyElement whenever we encounter a 
    15611572 *          storage object.  The optimisation reside in the usage of another
    1562  *          enumeration stategy that would give all the leaves of a storage
     1573 *          enumeration stategy that would give all the leaves of a storage 
    15631574 *          first. (postfix order)
    15641575 */
    1565 HRESULT WINAPI StorageImpl_DestroyElement(
     1576HRESULT WINAPI StorageImpl_DestroyElement( 
    15661577  IStorage*     iface,
    1567   const OLECHAR *pwcsName)/* [string][in] */
     1578  const OLECHAR *pwcsName)/* [string][in] */ 
    15681579{
    15691580  StorageImpl* const This=(StorageImpl*)iface;
     
    15781589  ULONG             parentPropertyId;
    15791590
    1580   TRACE("(%p, %s)\n",
    1581     iface, debugstr_w(pwcsName));
     1591  TRACE("(%p, %s)\n", 
     1592        iface, debugstr_w(pwcsName));
    15821593
    15831594  /*
    15841595   * Perform a sanity check on the parameters.
    15851596   */
    1586   if (pwcsName==NULL)
     1597  if (pwcsName==NULL) 
    15871598    return STG_E_INVALIDPOINTER;
    1588 
     1599 
    15891600  /*
    15901601   * Create a property enumeration to search the property with the given name
    15911602   */
    15921603  propertyEnumeration = IEnumSTATSTGImpl_Construct(
    1593     This->ancestorStorage,
     1604    This->ancestorStorage, 
    15941605    This->rootPropertySetIndex);
    1595 
     1606 
    15961607  foundPropertyIndexToDelete = IEnumSTATSTGImpl_FindProperty(
    15971608    propertyEnumeration,
     
    16011612  IEnumSTATSTGImpl_Destroy(propertyEnumeration);
    16021613
    1603   if ( foundPropertyIndexToDelete == PROPERTY_NULL )
     1614  if ( foundPropertyIndexToDelete == PROPERTY_NULL ) 
    16041615  {
    16051616    return STG_E_FILENOTFOUND;
    16061617  }
    16071618
    1608   /*
    1609    * Find the parent property of the property to delete (the one that
    1610    * link to it).  If This->dirProperty == foundPropertyIndexToDelete,
     1619  /* 
     1620   * Find the parent property of the property to delete (the one that 
     1621   * link to it).  If This->dirProperty == foundPropertyIndexToDelete, 
    16111622   * the parent is This. Otherwise, the parent is one of it's sibling...
    16121623   */
    16131624
    1614   /*
     1625  /* 
    16151626   * First, read This's StgProperty..
    16161627   */
    1617   res = StorageImpl_ReadProperty(
     1628  res = StorageImpl_ReadProperty( 
    16181629          This->ancestorStorage,
    16191630          This->rootPropertySetIndex,
     
    16221633  assert(res==TRUE);
    16231634
    1624   /*
     1635  /* 
    16251636   * Second, check to see if by any chance the actual storage (This) is not
    16261637   * the parent of the property to delete... We never know...
     
    16281639  if ( parentProperty.dirProperty == foundPropertyIndexToDelete )
    16291640  {
    1630     /*
     1641    /* 
    16311642     * Set data as it would have been done in the else part...
    16321643     */
     
    16341645    parentPropertyId = This->rootPropertySetIndex;
    16351646  }
    1636   else
    1637   {
    1638     /*
    1639      * Create a property enumeration to search the parent properties, and
     1647  else 
     1648  { 
     1649    /*
     1650     * Create a property enumeration to search the parent properties, and 
    16401651     * delete it once done.
    16411652     */
     
    16431654
    16441655    propertyEnumeration2 = IEnumSTATSTGImpl_Construct(
    1645       This->ancestorStorage,
     1656      This->ancestorStorage, 
    16461657      This->rootPropertySetIndex);
    1647 
     1658 
    16481659    typeOfRelation = IEnumSTATSTGImpl_FindParentProperty(
    16491660      propertyEnumeration2,
     
    16551666  }
    16561667
    1657   if ( propertyToDelete.propertyType == PROPTYPE_STORAGE )
     1668  if ( propertyToDelete.propertyType == PROPTYPE_STORAGE ) 
    16581669  {
    16591670    hr = deleteStorageProperty(
    1660            This,
     1671           This, 
    16611672           foundPropertyIndexToDelete,
    16621673           propertyToDelete);
    1663   }
     1674  } 
    16641675  else if ( propertyToDelete.propertyType == PROPTYPE_STREAM )
    16651676  {
    16661677    hr = deleteStreamProperty(
    1667            This,
     1678           This, 
    16681679           foundPropertyIndexToDelete,
    16691680           propertyToDelete);
    16701681  }
    16711682
    1672   if (hr!=S_OK)
     1683  if (hr!=S_OK) 
    16731684    return hr;
    16741685
     
    16781689  hr = adjustPropertyChain(
    16791690        This,
    1680         propertyToDelete,
     1691        propertyToDelete, 
    16811692        parentProperty,
    16821693        parentPropertyId,
     
    17221733  }
    17231734
    1724   /*
     1735  /* 
    17251736   * Enumerate the elements
    17261737   */
     
    17361747    {
    17371748      destroyHr = StorageImpl_DestroyElement(
    1738                     (IStorage*)childStorage,
     1749                    (IStorage*)childStorage, 
    17391750                    (OLECHAR*)currentElement.pwcsName);
    17401751
     
    17611772  IStorage_Release(childStorage);
    17621773  IEnumSTATSTG_Release(elements);
    1763 
     1774   
    17641775  return destroyHr;
    17651776}
     
    17911802         0,
    17921803         &pis);
    1793 
     1804   
    17941805  if (hr!=S_OK)
    17951806  {
     
    17971808  }
    17981809
    1799   /*
    1800    * Zap the stream
    1801    */
    1802   hr = IStream_SetSize(pis, size);
     1810  /* 
     1811   * Zap the stream 
     1812   */ 
     1813  hr = IStream_SetSize(pis, size); 
    18031814
    18041815  if(hr != S_OK)
     
    18121823  IStream_Release(pis);
    18131824
    1814   /*
     1825  /* 
    18151826   * Invalidate the property by zeroing it's name member.
    18161827   */
    18171828  propertyToDelete.sizeOfNameString = 0;
    18181829
    1819   /*
     1830  /* 
    18201831   * Here we should re-read the property so we get the updated pointer
    18211832   * but since we are here to zap it, I don't do it...
    18221833   */
    18231834  StorageImpl_WriteProperty(
    1824     parentStorage->ancestorStorage,
     1835    parentStorage->ancestorStorage, 
    18251836    indexOfPropertyToDelete,
    18261837    &propertyToDelete);
     
    18511862  res = StorageImpl_ReadProperty(
    18521863          storage->ancestorStorage,
    1853           storePropertyIndex,
     1864          storePropertyIndex, 
    18541865          &storeProperty);
    18551866
     
    18651876      return findPlaceholder(
    18661877               storage,
    1867                propertyIndexToStore,
     1878               propertyIndexToStore, 
    18681879               storeProperty.previousProperty,
    18691880               typeOfRelation);
     
    18801891      return findPlaceholder(
    18811892               storage,
    1882                propertyIndexToStore,
     1893               propertyIndexToStore, 
    18831894               storeProperty.nextProperty,
    18841895               typeOfRelation);
     
    18881899      storeProperty.nextProperty = propertyIndexToStore;
    18891900    }
    1890   }
     1901  } 
    18911902  else if (typeOfRelation == PROPERTY_RELATION_DIR)
    18921903  {
     
    18951906      return findPlaceholder(
    18961907               storage,
    1897                propertyIndexToStore,
     1908               propertyIndexToStore, 
    18981909               storeProperty.dirProperty,
    18991910               typeOfRelation);
     
    19071918  hr = StorageImpl_WriteProperty(
    19081919         storage->ancestorStorage,
    1909          storePropertyIndex,
     1920         storePropertyIndex, 
    19101921         &storeProperty);
    19111922
     
    19221933 * Internal Method
    19231934 *
    1924  * This method takes the previous and the next property link of a property
     1935 * This method takes the previous and the next property link of a property 
    19251936 * to be deleted and find them a place in the Storage.
    19261937 */
    1927 static HRESULT adjustPropertyChain(
     1938static HRESULT adjustPropertyChain( 
    19281939  StorageImpl *This,
    19291940  StgProperty   propertyToDelete,
     
    19391950  HRESULT hr                     = S_OK;
    19401951  BOOL  res                    = TRUE;
    1941 
    1942   if (typeOfRelation == PROPERTY_RELATION_PREVIOUS)
    1943   {
    1944     if (propertyToDelete.previousProperty != PROPERTY_NULL)
    1945     {
    1946       /*
     1952 
     1953  if (typeOfRelation == PROPERTY_RELATION_PREVIOUS) 
     1954  {
     1955    if (propertyToDelete.previousProperty != PROPERTY_NULL) 
     1956    {
     1957      /* 
    19471958       * Set the parent previous to the property to delete previous
    19481959       */
    19491960      newLinkProperty = propertyToDelete.previousProperty;
    19501961
    1951       if (propertyToDelete.nextProperty != PROPERTY_NULL)
     1962      if (propertyToDelete.nextProperty != PROPERTY_NULL) 
    19521963      {
    19531964        /*
    1954          * We also need to find a storage for the other link, setup variables
     1965         * We also need to find a storage for the other link, setup variables 
    19551966         * to do this at the end...
    1956          */
     1967         */     
    19571968        needToFindAPlaceholder = TRUE;
    19581969        storeNode              = propertyToDelete.previousProperty;
     
    19601971        relationType           = PROPERTY_RELATION_NEXT;
    19611972      }
    1962     }
    1963     else if (propertyToDelete.nextProperty != PROPERTY_NULL)
    1964     {
    1965       /*
     1973    } 
     1974    else if (propertyToDelete.nextProperty != PROPERTY_NULL) 
     1975    {
     1976      /* 
    19661977       * Set the parent previous to the property to delete next
    19671978       */
    19681979      newLinkProperty = propertyToDelete.nextProperty;
    19691980    }
    1970 
    1971     /*
     1981   
     1982    /* 
    19721983     * Link it for real...
    1973      */
     1984     */ 
    19741985    parentProperty.previousProperty = newLinkProperty;
    1975 
    1976   }
    1977   else if (typeOfRelation == PROPERTY_RELATION_NEXT)
    1978   {
    1979     if (propertyToDelete.previousProperty != PROPERTY_NULL)
    1980     {
    1981       /*
     1986 
     1987  } 
     1988  else if (typeOfRelation == PROPERTY_RELATION_NEXT) 
     1989  {
     1990    if (propertyToDelete.previousProperty != PROPERTY_NULL) 
     1991    {
     1992      /* 
    19821993       * Set the parent next to the property to delete next previous
    19831994       */
    19841995      newLinkProperty = propertyToDelete.previousProperty;
    1985 
    1986       if (propertyToDelete.nextProperty != PROPERTY_NULL)
     1996     
     1997      if (propertyToDelete.nextProperty != PROPERTY_NULL) 
    19871998      {
    19881999        /*
    1989          * We also need to find a storage for the other link, setup variables
     2000         * We also need to find a storage for the other link, setup variables 
    19902001         * to do this at the end...
    1991          */
     2002         */     
    19922003        needToFindAPlaceholder = TRUE;
    19932004        storeNode              = propertyToDelete.previousProperty;
     
    19952006        relationType           = PROPERTY_RELATION_NEXT;
    19962007      }
    1997     }
    1998     else if (propertyToDelete.nextProperty != PROPERTY_NULL)
    1999     {
    2000       /*
     2008    } 
     2009    else if (propertyToDelete.nextProperty != PROPERTY_NULL) 
     2010    {
     2011      /* 
    20012012       * Set the parent next to the property to delete next
    20022013       */
     
    20042015    }
    20052016
    2006     /*
     2017    /* 
    20072018     * Link it for real...
    2008      */
     2019     */ 
    20092020    parentProperty.nextProperty = newLinkProperty;
    2010   }
     2021  } 
    20112022  else /* (typeOfRelation == PROPERTY_RELATION_DIR) */
    20122023  {
    2013     if (propertyToDelete.previousProperty != PROPERTY_NULL)
    2014     {
    2015       /*
     2024    if (propertyToDelete.previousProperty != PROPERTY_NULL) 
     2025    {
     2026      /* 
    20162027       * Set the parent dir to the property to delete previous
    20172028       */
    20182029      newLinkProperty = propertyToDelete.previousProperty;
    20192030
    2020       if (propertyToDelete.nextProperty != PROPERTY_NULL)
     2031      if (propertyToDelete.nextProperty != PROPERTY_NULL) 
    20212032      {
    20222033        /*
    2023          * We also need to find a storage for the other link, setup variables
     2034         * We also need to find a storage for the other link, setup variables 
    20242035         * to do this at the end...
    2025          */
     2036         */     
    20262037        needToFindAPlaceholder = TRUE;
    20272038        storeNode              = propertyToDelete.previousProperty;
     
    20292040        relationType           = PROPERTY_RELATION_NEXT;
    20302041      }
    2031     }
    2032     else if (propertyToDelete.nextProperty != PROPERTY_NULL)
    2033     {
    2034       /*
     2042    } 
     2043    else if (propertyToDelete.nextProperty != PROPERTY_NULL) 
     2044    {
     2045      /* 
    20352046       * Set the parent dir to the property to delete next
    20362047       */
     
    20382049    }
    20392050
    2040     /*
     2051    /* 
    20412052     * Link it for real...
    2042      */
     2053     */ 
    20432054    parentProperty.dirProperty = newLinkProperty;
    20442055  }
    20452056
    2046   /*
    2047    * Write back the parent property
     2057  /* 
     2058   * Write back the parent property   
    20482059   */
    20492060  res = StorageImpl_WriteProperty(
    2050           This->ancestorStorage,
     2061          This->ancestorStorage, 
    20512062          parentPropertyId,
    20522063          &parentProperty);
     
    20572068
    20582069  /*
    2059    * If a placeholder is required for the other link, then, find one and
     2070   * If a placeholder is required for the other link, then, find one and 
    20602071   * get out of here...
    20612072   */
    2062   if (needToFindAPlaceholder)
     2073  if (needToFindAPlaceholder) 
    20632074  {
    20642075    hr = findPlaceholder(
    2065            This,
    2066            toStoreNode,
     2076           This, 
     2077           toStoreNode, 
    20672078           storeNode,
    20682079           relationType);
     
    20762087 * SetElementTimes (IStorage)
    20772088 */
    2078 HRESULT WINAPI StorageImpl_SetElementTimes(
     2089HRESULT WINAPI StorageImpl_SetElementTimes( 
    20792090  IStorage*     iface,
    2080   const OLECHAR *pwcsName,/* [string][in] */
    2081   const FILETIME  *pctime,  /* [in] */
    2082   const FILETIME  *patime,  /* [in] */
    2083   const FILETIME  *pmtime)  /* [in] */
     2091  const OLECHAR *pwcsName,/* [string][in] */ 
     2092  const FILETIME  *pctime,  /* [in] */ 
     2093  const FILETIME  *patime,  /* [in] */ 
     2094  const FILETIME  *pmtime)  /* [in] */ 
    20842095{
    20852096  FIXME("not implemented!\n");
     
    20902101 * SetStateBits (IStorage)
    20912102 */
    2092 HRESULT WINAPI StorageImpl_SetStateBits(
     2103HRESULT WINAPI StorageImpl_SetStateBits( 
    20932104  IStorage*   iface,
    2094   DWORD         grfStateBits,/* [in] */
    2095   DWORD         grfMask)     /* [in] */
     2105  DWORD         grfStateBits,/* [in] */ 
     2106  DWORD         grfMask)     /* [in] */ 
    20962107{
    20972108  FIXME("not implemented!\n");
     
    21112122  BOOL      readSuccessful;
    21122123  ULONG       currentPropertyIndex;
    2113 
     2124 
    21142125  if ( FAILED( validateSTGM(openFlags) ))
    21152126    return STG_E_INVALIDFLAG;
    21162127
    21172128  memset(This, 0, sizeof(StorageImpl));
    2118 
     2129 
    21192130  /*
    21202131   * Initialize the virtual fgunction table.
     
    21222133  ICOM_VTBL(This)    = &Storage32Impl_Vtbl;
    21232134  This->v_destructor = &StorageImpl_Destroy;
    2124 
     2135 
    21252136  /*
    21262137   * This is the top-level storage so initialize the ancester pointer
     
    21282139   */
    21292140  This->ancestorStorage = This;
    2130 
     2141 
    21312142  /*
    21322143   * Initialize the physical support of the storage.
    21332144   */
    21342145  This->hFile = hFile;
    2135 
     2146 
    21362147  /*
    21372148   * Initialize the big block cache.
     
    21472158  if (This->bigBlockFile == 0)
    21482159    return E_FAIL;
    2149 
     2160 
    21502161  if (fileCreate)
    21512162  {
     
    21592170     * - There is no small block depot
    21602171     */
    2161     memset( This->bigBlockDepotStart,
    2162             BLOCK_UNUSED,
     2172    memset( This->bigBlockDepotStart,     
     2173            BLOCK_UNUSED, 
    21632174            sizeof(This->bigBlockDepotStart));
    21642175
     
    22142225   */
    22152226  This->prevFreeBlock = 0;
    2216 
     2227 
    22172228  /*
    22182229   * Create the block chain abstractions.
    22192230   */
    2220   This->rootBlockChain =
     2231  This->rootBlockChain = 
    22212232    BlockChainStream_Construct(This, &This->rootStartBlock, PROPERTY_NULL);
    22222233
    22232234  This->smallBlockDepotChain = BlockChainStream_Construct(
    2224                                  This,
    2225                                  &This->smallBlockDepotStart,
     2235                                 This, 
     2236                                 &This->smallBlockDepotStart, 
    22262237                                 PROPERTY_NULL);
    22272238
    22282239  /*
    2229    * Write the root property
     2240   * Write the root property 
    22302241   */
    22312242  if (fileCreate)
     
    22542265   */
    22552266  currentPropertyIndex = 0;
    2256 
     2267 
    22572268  do
    22582269  {
    22592270    readSuccessful = StorageImpl_ReadProperty(
    2260                       This,
    2261                       currentPropertyIndex,
     2271                      This, 
     2272                      currentPropertyIndex, 
    22622273                      &currentProperty);
    2263 
     2274   
    22642275    if (readSuccessful)
    22652276    {
     
    22722283
    22732284    currentPropertyIndex++;
    2274 
     2285   
    22752286  } while (readSuccessful && (This->rootPropertySetIndex == PROPERTY_NULL) );
    2276 
     2287 
    22772288  if (!readSuccessful)
    22782289  {
     
    22852296   */
    22862297  This->smallBlockRootChain = BlockChainStream_Construct(
    2287                                 This,
    2288                                 NULL,
     2298                                This, 
     2299                                NULL, 
    22892300                                This->rootPropertySetIndex);
    2290 
     2301 
    22912302  return hr;
    22922303}
     
    28212832
    28222833    StorageUtl_ReadWord(
    2823       headerBigBlock,
    2824       OFFSET_BIGBLOCKSIZEBITS,
     2834      headerBigBlock, 
     2835      OFFSET_BIGBLOCKSIZEBITS,   
    28252836      &This->bigBlockSizeBits);
    28262837
    28272838    StorageUtl_ReadWord(
    2828       headerBigBlock,
    2829       OFFSET_SMALLBLOCKSIZEBITS,
     2839      headerBigBlock, 
     2840      OFFSET_SMALLBLOCKSIZEBITS, 
    28302841      &This->smallBlockSizeBits);
    28312842
    28322843    StorageUtl_ReadDWord(
    2833       headerBigBlock,
    2834       OFFSET_BBDEPOTCOUNT,
     2844      headerBigBlock, 
     2845      OFFSET_BBDEPOTCOUNT,     
    28352846      &This->bigBlockDepotCount);
    28362847
    28372848    StorageUtl_ReadDWord(
    2838       headerBigBlock,
    2839       OFFSET_ROOTSTARTBLOCK,
     2849      headerBigBlock, 
     2850      OFFSET_ROOTSTARTBLOCK,   
    28402851      &This->rootStartBlock);
    28412852
    28422853    StorageUtl_ReadDWord(
    2843       headerBigBlock,
    2844       OFFSET_SBDEPOTSTART,
     2854      headerBigBlock, 
     2855      OFFSET_SBDEPOTSTART,     
    28452856      &This->smallBlockDepotStart);
    28462857
     2858    StorageUtl_ReadDWord(
     2859      headerBigBlock,
     2860      OFFSET_EXTBBDEPOTSTART,   
     2861      &This->extBigBlockDepotStart);
     2862
    28472863    StorageUtl_ReadDWord(
    2848       headerBigBlock,
    2849       OFFSET_EXTBBDEPOTSTART,
    2850       &This->extBigBlockDepotStart);
    2851 
    2852     StorageUtl_ReadDWord(
    2853       headerBigBlock,
    2854       OFFSET_EXTBBDEPOTCOUNT,
     2864      headerBigBlock,
     2865      OFFSET_EXTBBDEPOTCOUNT,   
    28552866      &This->extBigBlockDepotCount);
    2856 
     2867   
    28572868    for (index = 0; index < COUNT_BBDEPOTINHEADER; index ++)
    28582869    {
    28592870      StorageUtl_ReadDWord(
    2860         headerBigBlock,
     2871        headerBigBlock, 
    28612872        OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
    28622873        &(This->bigBlockDepotStart[index]));
    28632874    }
    2864 
     2875   
    28652876    /*
    28662877     * Make the bitwise arithmetic to get the size of the blocks in bytes.
     
    28762887      This->smallBlockSize = 0x000000001 >> (DWORD)This->smallBlockSizeBits;
    28772888    }
    2878 
    2879     /*
    2880      * Right now, the code is making some assumptions about the size of the
     2889   
     2890    /*
     2891     * Right now, the code is making some assumptions about the size of the 
    28812892     * blocks, just make sure they are what we're expecting.
    28822893     */
    2883     assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) &&
     2894    assert( (This->bigBlockSize==DEF_BIG_BLOCK_SIZE) && 
    28842895            (This->smallBlockSize==DEF_SMALL_BLOCK_SIZE));
    2885 
     2896   
    28862897    /*
    28872898     * Release the block.
     
    28912902    hr = S_OK;
    28922903  }
    2893 
     2904 
    28942905  return hr;
    28952906}
     
    29112922   */
    29122923  success = StorageImpl_ReadBigBlock(This, -1, headerBigBlock);
    2913 
     2924 
    29142925  /*
    29152926   * If the block read failed, the file is probably new.
     
    29212932     */
    29222933    memset(headerBigBlock, 0, BIG_BLOCK_SIZE);
    2923 
     2934   
    29242935    /*
    29252936     * Initialize the magic number.
    29262937     */
    29272938    memcpy(headerBigBlock, STORAGE_magic, sizeof(STORAGE_magic));
    2928 
     2939   
    29292940    /*
    29302941     * And a bunch of things we don't know what they mean
     
    29362947    StorageUtl_WriteDWord(headerBigBlock, 0x40, (DWORD)0x0001);
    29372948  }
    2938 
     2949 
    29392950  /*
    29402951   * Write the information to the header.
     
    29432954  {
    29442955    StorageUtl_WriteWord(
    2945       headerBigBlock,
    2946       OFFSET_BIGBLOCKSIZEBITS,
     2956      headerBigBlock, 
     2957      OFFSET_BIGBLOCKSIZEBITS,   
    29472958      This->bigBlockSizeBits);
    29482959
    29492960    StorageUtl_WriteWord(
    2950       headerBigBlock,
    2951       OFFSET_SMALLBLOCKSIZEBITS,
     2961      headerBigBlock, 
     2962      OFFSET_SMALLBLOCKSIZEBITS, 
    29522963      This->smallBlockSizeBits);
    29532964
    29542965    StorageUtl_WriteDWord(
    2955       headerBigBlock,
    2956       OFFSET_BBDEPOTCOUNT,
     2966      headerBigBlock, 
     2967      OFFSET_BBDEPOTCOUNT,     
    29572968      This->bigBlockDepotCount);
    29582969
    29592970    StorageUtl_WriteDWord(
    2960       headerBigBlock,
    2961       OFFSET_ROOTSTARTBLOCK,
     2971      headerBigBlock, 
     2972      OFFSET_ROOTSTARTBLOCK,   
    29622973      This->rootStartBlock);
    29632974
    29642975    StorageUtl_WriteDWord(
    2965       headerBigBlock,
    2966       OFFSET_SBDEPOTSTART,
     2976      headerBigBlock, 
     2977      OFFSET_SBDEPOTSTART,     
    29672978      This->smallBlockDepotStart);
    29682979
    29692980    StorageUtl_WriteDWord(
    2970       headerBigBlock,
    2971       OFFSET_EXTBBDEPOTSTART,
     2981      headerBigBlock, 
     2982      OFFSET_EXTBBDEPOTSTART,   
    29722983      This->extBigBlockDepotStart);
    29732984
    29742985    StorageUtl_WriteDWord(
    2975       headerBigBlock,
    2976       OFFSET_EXTBBDEPOTCOUNT,
     2986      headerBigBlock, 
     2987      OFFSET_EXTBBDEPOTCOUNT,   
    29772988      This->extBigBlockDepotCount);
    29782989
     
    29802991    {
    29812992      StorageUtl_WriteDWord(
    2982         headerBigBlock,
     2993        headerBigBlock, 
    29832994        OFFSET_BBDEPOTSTART + (sizeof(ULONG)*index),
    29842995        (This->bigBlockDepotStart[index]));
    29852996    }
    29862997  }
    2987 
     2998 
    29882999  /*
    29893000   * Write the big block back to the file.
     
    30093020  offsetInPropSet.s.HighPart = 0;
    30103021  offsetInPropSet.s.LowPart  = index * PROPSET_BLOCK_SIZE;
    3011 
     3022 
    30123023  readSuccessful = BlockChainStream_ReadAt(
    30133024                    This->rootBlockChain,
     
    30163027                    currentProperty,
    30173028                    &bytesRead);
    3018 
     3029 
    30193030  if (readSuccessful)
    30203031  {
    30213032    memset(buffer->name, 0, sizeof(buffer->name));
    30223033    memcpy(
    3023       buffer->name,
    3024       currentProperty+OFFSET_PS_NAME,
     3034      buffer->name, 
     3035      currentProperty+OFFSET_PS_NAME, 
    30253036      PROPERTY_NAME_BUFFER_LEN );
    30263037
    30273038    memcpy(&buffer->propertyType, currentProperty + OFFSET_PS_PROPERTYTYPE, 1);
    3028 
     3039   
    30293040    StorageUtl_ReadWord(
    3030       currentProperty,
    3031       OFFSET_PS_NAMELENGTH,
     3041      currentProperty, 
     3042      OFFSET_PS_NAMELENGTH, 
    30323043      &buffer->sizeOfNameString);
    30333044
    30343045    StorageUtl_ReadDWord(
    3035       currentProperty,
    3036       OFFSET_PS_PREVIOUSPROP,
     3046      currentProperty, 
     3047      OFFSET_PS_PREVIOUSPROP, 
    30373048      &buffer->previousProperty);
    30383049
    30393050    StorageUtl_ReadDWord(
    3040       currentProperty,
    3041       OFFSET_PS_NEXTPROP,
     3051      currentProperty, 
     3052      OFFSET_PS_NEXTPROP,     
    30423053      &buffer->nextProperty);
    30433054
    30443055    StorageUtl_ReadDWord(
    3045       currentProperty,
    3046       OFFSET_PS_DIRPROP,
     3056      currentProperty, 
     3057      OFFSET_PS_DIRPROP,     
    30473058      &buffer->dirProperty);
    30483059
    30493060    StorageUtl_ReadGUID(
    3050       currentProperty,
    3051       OFFSET_PS_GUID,
     3061      currentProperty, 
     3062      OFFSET_PS_GUID,       
    30523063      &buffer->propertyUniqueID);
    30533064
    30543065    StorageUtl_ReadDWord(
    3055       currentProperty,
    3056       OFFSET_PS_TSS1,
     3066      currentProperty, 
     3067      OFFSET_PS_TSS1,         
    30573068      &buffer->timeStampS1);
    30583069
    30593070    StorageUtl_ReadDWord(
    3060       currentProperty,
    3061       OFFSET_PS_TSD1,
     3071      currentProperty, 
     3072      OFFSET_PS_TSD1,         
    30623073      &buffer->timeStampD1);
    30633074
    30643075    StorageUtl_ReadDWord(
    3065       currentProperty,
    3066       OFFSET_PS_TSS2,
     3076      currentProperty, 
     3077      OFFSET_PS_TSS2,         
    30673078      &buffer->timeStampS2);
    30683079
    30693080    StorageUtl_ReadDWord(
    3070       currentProperty,
    3071       OFFSET_PS_TSD2,
     3081      currentProperty, 
     3082      OFFSET_PS_TSD2,         
    30723083      &buffer->timeStampD2);
    30733084
    30743085    StorageUtl_ReadDWord(
    3075       currentProperty,
    3076       OFFSET_PS_STARTBLOCK,
     3086      currentProperty, 
     3087      OFFSET_PS_STARTBLOCK,   
    30773088      &buffer->startingBlock);
    30783089
    30793090    StorageUtl_ReadDWord(
    3080       currentProperty,
    3081       OFFSET_PS_SIZE,
     3091      currentProperty, 
     3092      OFFSET_PS_SIZE,         
    30823093      &buffer->size.s.LowPart);
    30833094
     
    31073118
    31083119  memcpy(
    3109     currentProperty + OFFSET_PS_NAME,
    3110     buffer->name,
     3120    currentProperty + OFFSET_PS_NAME, 
     3121    buffer->name, 
    31113122    PROPERTY_NAME_BUFFER_LEN );
    31123123
     
    31143125
    31153126  StorageUtl_WriteWord(
    3116     currentProperty,
    3117       OFFSET_PS_NAMELENGTH,
     3127    currentProperty, 
     3128      OFFSET_PS_NAMELENGTH,   
    31183129      buffer->sizeOfNameString);
    31193130
    31203131  StorageUtl_WriteDWord(
    3121     currentProperty,
    3122       OFFSET_PS_PREVIOUSPROP,
     3132    currentProperty, 
     3133      OFFSET_PS_PREVIOUSPROP, 
    31233134      buffer->previousProperty);
    31243135
    31253136  StorageUtl_WriteDWord(
    3126     currentProperty,
    3127       OFFSET_PS_NEXTPROP,
     3137    currentProperty, 
     3138      OFFSET_PS_NEXTPROP,     
    31283139      buffer->nextProperty);
    31293140
    31303141  StorageUtl_WriteDWord(
    3131     currentProperty,
    3132       OFFSET_PS_DIRPROP,
     3142    currentProperty, 
     3143      OFFSET_PS_DIRPROP,     
    31333144      buffer->dirProperty);
    31343145
    31353146  StorageUtl_WriteGUID(
    3136     currentProperty,
    3137       OFFSET_PS_GUID,
     3147    currentProperty, 
     3148      OFFSET_PS_GUID,       
    31383149      &buffer->propertyUniqueID);
    31393150
    31403151  StorageUtl_WriteDWord(
    3141     currentProperty,
    3142       OFFSET_PS_TSS1,
     3152    currentProperty, 
     3153      OFFSET_PS_TSS1,         
    31433154      buffer->timeStampS1);
    31443155
    31453156  StorageUtl_WriteDWord(
    3146     currentProperty,
    3147       OFFSET_PS_TSD1,
     3157    currentProperty, 
     3158      OFFSET_PS_TSD1,         
    31483159      buffer->timeStampD1);
    31493160
    31503161  StorageUtl_WriteDWord(
    3151     currentProperty,
    3152       OFFSET_PS_TSS2,
     3162    currentProperty, 
     3163      OFFSET_PS_TSS2,         
    31533164      buffer->timeStampS2);
    31543165
    31553166  StorageUtl_WriteDWord(
    3156     currentProperty,
    3157       OFFSET_PS_TSD2,
     3167    currentProperty, 
     3168      OFFSET_PS_TSD2,         
    31583169      buffer->timeStampD2);
    31593170
    31603171  StorageUtl_WriteDWord(
    3161     currentProperty,
    3162       OFFSET_PS_STARTBLOCK,
     3172    currentProperty, 
     3173      OFFSET_PS_STARTBLOCK,   
    31633174      buffer->startingBlock);
    31643175
    31653176  StorageUtl_WriteDWord(
    3166     currentProperty,
    3167       OFFSET_PS_SIZE,
     3177    currentProperty, 
     3178      OFFSET_PS_SIZE,         
    31683179      buffer->size.s.LowPart);
    31693180
     
    32113222
    32123223    StorageImpl_ReleaseBigBlock(This, bigBlockBuffer);
    3213 
     3224   
    32143225    return TRUE;
    32153226  }
    3216 
     3227 
    32173228  return FALSE;
    32183229}
     
    33443355
    33453356StorageInternalImpl* StorageInternalImpl_Construct(
    3346   StorageImpl* ancestorStorage,
     3357  StorageImpl* ancestorStorage, 
    33473358  ULONG          rootPropertyIndex)
    33483359{
     
    33953406** does nothing.
    33963407*/
    3397 HRESULT WINAPI StorageInternalImpl_Commit(
     3408HRESULT WINAPI StorageInternalImpl_Commit( 
    33983409  IStorage*            iface,
    3399   DWORD                  grfCommitFlags)  /* [in] */
     3410  DWORD                  grfCommitFlags)  /* [in] */ 
    34003411{
    34013412  return S_OK;
    34023413}
    3403 
     3414       
    34043415/******************************************************************************
    34053416**
     
    34093420** does nothing.
    34103421*/
    3411 HRESULT WINAPI StorageInternalImpl_Revert(
     3422HRESULT WINAPI StorageInternalImpl_Revert( 
    34123423  IStorage*            iface)
    34133424{
     
    34263437
    34273438  newEnumeration = HeapAlloc(GetProcessHeap(), 0, sizeof(IEnumSTATSTGImpl));
    3428 
     3439 
    34293440  if (newEnumeration!=0)
    34303441  {
     
    34343445    ICOM_VTBL(newEnumeration) = &IEnumSTATSTGImpl_Vtbl;
    34353446    newEnumeration->ref       = 0;
    3436 
     3447   
    34373448    /*
    34383449     * We want to nail-down the reference to the storage in case the
     
    34413452    newEnumeration->parentStorage = parentStorage;
    34423453    IStorage_AddRef((IStorage*)newEnumeration->parentStorage);
    3443 
     3454   
    34443455    newEnumeration->firstPropertyNode   = firstPropertyNode;
    3445 
     3456   
    34463457    /*
    34473458     * Initialize the search stack
     
    34493460    newEnumeration->stackSize    = 0;
    34503461    newEnumeration->stackMaxSize = ENUMSTATSGT_SIZE_INCREMENT;
    3451     newEnumeration->stackToVisit =
     3462    newEnumeration->stackToVisit = 
    34523463      HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG)*ENUMSTATSGT_SIZE_INCREMENT);
    3453 
     3464   
    34543465    /*
    34553466     * Make sure the current node of the iterator is the first one.
     
    34573468    IEnumSTATSTGImpl_Reset((IEnumSTATSTG*)newEnumeration);
    34583469  }
    3459 
     3470 
    34603471  return newEnumeration;
    34613472}
     
    34893500   * Compare the riid with the interface IDs implemented by this object.
    34903501   */
    3491   if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0)
     3502  if (memcmp(&IID_IUnknown, riid, sizeof(IID_IUnknown)) == 0) 
    34923503  {
    34933504    *ppvObject = (IEnumSTATSTG*)This;
    34943505  }
    3495   else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0)
     3506  else if (memcmp(&IID_IStorage, riid, sizeof(IID_IEnumSTATSTG)) == 0) 
    34963507  {
    34973508    *ppvObject = (IEnumSTATSTG*)This;
     
    35123523  return S_OK;
    35133524}
    3514 
     3525       
    35153526ULONG   WINAPI IEnumSTATSTGImpl_AddRef(
    35163527  IEnumSTATSTG* iface)
     
    35213532  return This->ref;
    35223533}
    3523 
     3534       
    35243535ULONG   WINAPI IEnumSTATSTGImpl_Release(
    35253536  IEnumSTATSTG* iface)
     
    35603571   */
    35613572  if ( (rgelt==0) || ( (celt!=1) && (pceltFetched==0) ) )
    3562     return E_INVALIDARG;
    3563 
     3573    return E_INVALIDARG; 
     3574 
    35643575  /*
    35653576   * To avoid the special case, get another pointer to a ULONG value if
     
    35683579  if (pceltFetched==0)
    35693580    pceltFetched = &objectFetched;
    3570 
     3581 
    35713582  /*
    35723583   * Start the iteration, we will iterate until we hit the end of the
     
    35803591  currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE);
    35813592
    3582   while ( ( *pceltFetched < celt) &&
     3593  while ( ( *pceltFetched < celt) && 
    35833594          ( currentSearchNode!=PROPERTY_NULL) )
    35843595  {
    3585     /*
     3596    /* 
    35863597     * Remove the top node from the stack
    35873598     */
     
    35923603     */
    35933604    StorageImpl_ReadProperty(This->parentStorage,
    3594       currentSearchNode,
     3605      currentSearchNode, 
    35953606      &currentProperty);
    35963607
     
    36013612      &currentProperty,
    36023613      STATFLAG_DEFAULT);
    3603 
     3614       
    36043615    /*
    36053616     * Step to the next item in the iteration
     
    36253636}
    36263637
    3627 
     3638       
    36283639HRESULT WINAPI IEnumSTATSTGImpl_Skip(
    36293640  IEnumSTATSTG* iface,
     
    36413652  currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE);
    36423653
    3643   while ( (objectFetched < celt) &&
     3654  while ( (objectFetched < celt) && 
    36443655          (currentSearchNode!=PROPERTY_NULL) )
    36453656  {
    3646     /*
     3657    /* 
    36473658     * Remove the top node from the stack
    36483659     */
     
    36533664     */
    36543665    StorageImpl_ReadProperty(This->parentStorage,
    3655       currentSearchNode,
     3666      currentSearchNode, 
    36563667      &currentProperty);
    3657 
     3668   
    36583669    /*
    36593670     * Step to the next item in the iteration
     
    36773688  return S_FALSE;
    36783689}
    3679 
     3690       
    36803691HRESULT WINAPI IEnumSTATSTGImpl_Reset(
    36813692  IEnumSTATSTG* iface)
     
    36963707  readSuccessful = StorageImpl_ReadProperty(
    36973708                    This->parentStorage,
    3698                     This->firstPropertyNode,
     3709                    This->firstPropertyNode, 
    36993710                    &rootProperty);
    37003711
     
    37113722  return S_OK;
    37123723}
    3713 
     3724       
    37143725HRESULT WINAPI IEnumSTATSTGImpl_Clone(
    37153726  IEnumSTATSTG* iface,
     
    37253736  if (ppenum==0)
    37263737    return E_INVALIDARG;
    3727 
     3738 
    37283739  newClone = IEnumSTATSTGImpl_Construct(This->parentStorage,
    37293740               This->firstPropertyNode);
    37303741
    3731 
     3742 
    37323743  /*
    37333744   * The new clone enumeration must point to the same current node as
     
    37363747  newClone->stackSize    = This->stackSize    ;
    37373748  newClone->stackMaxSize = This->stackMaxSize ;
    3738   newClone->stackToVisit =
     3749  newClone->stackToVisit = 
    37393750    HeapAlloc(GetProcessHeap(), 0, sizeof(ULONG) * newClone->stackMaxSize);
    37403751
    37413752  memcpy(
    3742     newClone->stackToVisit,
    3743     This->stackToVisit,
     3753    newClone->stackToVisit, 
     3754    This->stackToVisit, 
    37443755    sizeof(ULONG) * newClone->stackSize);
    37453756
     
    37573768INT IEnumSTATSTGImpl_FindParentProperty(
    37583769  IEnumSTATSTGImpl *This,
    3759   ULONG             childProperty,
     3770  ULONG             childProperty, 
    37603771  StgProperty      *currentProperty,
    37613772  ULONG            *thisNodeId)
     
    37753786   */
    37763787  currentSearchNode = IEnumSTATSTGImpl_PopSearchNode(This, FALSE);
    3777 
     3788 
    37783789
    37793790  while (currentSearchNode!=PROPERTY_NULL)
     
    37843795    *thisNodeId = currentSearchNode;
    37853796
    3786     /*
     3797    /* 
    37873798     * Remove the top node from the stack
    37883799     */
     
    37943805    StorageImpl_ReadProperty(
    37953806      This->parentStorage,
    3796       currentSearchNode,
     3807      currentSearchNode, 
    37973808      currentProperty);
    3798 
     3809     
    37993810    if (currentProperty->previousProperty == childProperty)
    38003811      return PROPERTY_RELATION_PREVIOUS;
    38013812
    3802     else if (currentProperty->nextProperty == childProperty)
     3813    else if (currentProperty->nextProperty == childProperty) 
    38033814      return PROPERTY_RELATION_NEXT;
    3804 
     3815 
    38053816    else if (currentProperty->dirProperty == childProperty)
    38063817      return PROPERTY_RELATION_DIR;
    3807 
     3818       
    38083819    /*
    38093820     * Push the next search node in the search stack.
     
    38343845  while (currentSearchNode!=PROPERTY_NULL)
    38353846  {
    3836     /*
     3847    /* 
    38373848     * Remove the top node from the stack
    38383849     */
     
    38433854     */
    38443855    StorageImpl_ReadProperty(This->parentStorage,
    3845       currentSearchNode,
     3856      currentSearchNode, 
    38463857      currentProperty);
    38473858
    38483859    if ( propertyNameCmp(
    3849           (OLECHAR*)currentProperty->name,
     3860          (OLECHAR*)currentProperty->name, 
    38503861          (OLECHAR*)lpszPropName) == 0)
    38513862      return currentSearchNode;
     
    38863897
    38873898    This->stackToVisit = HeapReAlloc(
    3888                            GetProcessHeap(),
     3899                           GetProcessHeap(), 
    38893900                           0,
    38903901                           This->stackToVisit,
     
    39003911  readSuccessful = StorageImpl_ReadProperty(
    39013912                    This->parentStorage,
    3902                     nodeToPush,
     3913                    nodeToPush, 
    39033914                    &rootProperty);
    39043915
     
    39873998  else
    39883999  {
    3989     destination->pwcsName =
     4000    destination->pwcsName = 
    39904001      CoTaskMemAlloc((lstrlenW(source->name)+1)*sizeof(WCHAR));
    39914002
    39924003    strcpyW((LPWSTR)destination->pwcsName, source->name);
    39934004  }
    3994 
     4005 
    39954006  switch (source->propertyType)
    39964007  {
     
    40044015    default:
    40054016      destination->type = STGTY_STREAM;
    4006       break;
     4017      break;       
    40074018  }
    40084019
    40094020  destination->cbSize            = source->size;
    4010 /*
     4021/*   
    40114022  currentReturnStruct->mtime     = {0}; TODO
    40124023  currentReturnStruct->ctime     = {0};
    4013   currentReturnStruct->atime     = {0};
     4024  currentReturnStruct->atime     = {0}; 
    40144025*/
    40154026  destination->grfMode           = 0;
    4016   destination->grfLocksSupported = 0;
     4027  destination->grfLocksSupported = 0; 
    40174028  destination->clsid             = source->propertyUniqueID;
    4018   destination->grfStateBits      = 0;
    4019   destination->reserved          = 0;
     4029  destination->grfStateBits      = 0; 
     4030  destination->reserved          = 0; 
    40204031}
    40214032
     
    40254036
    40264037BlockChainStream* BlockChainStream_Construct(
    4027   StorageImpl* parentStorage,
     4038  StorageImpl* parentStorage, 
    40284039  ULONG*         headOfStreamPlaceHolder,
    40294040  ULONG          propertyIndex)
     
    40984109 * Returns the number of blocks that comprises this chain.
    40994110 * This is not the size of the stream as the last block may not be full!
    4100  *
     4111 * 
    41014112 */
    41024113ULONG BlockChainStream_GetCount(BlockChainStream* This)
     
    41124123
    41134124    blockIndex = StorageImpl_GetNextBlockInChain(
    4114                    This->parentStorage,
     4125                   This->parentStorage, 
    41154126                   blockIndex);
    41164127  }
     
    41204131
    41214132/******************************************************************************
    4122  *      BlockChainStream_ReadAt
     4133 *      BlockChainStream_ReadAt 
    41234134 *
    41244135 * Reads a specified number of bytes from this chain at the specified offset.
     
    41604171  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    41614172  {
    4162     blockIndex =
     4173    blockIndex = 
    41634174      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4164 
     4175   
    41654176    blockNoInSequence--;
    41664177  }
     
    41734184  *bytesRead   = 0;
    41744185  bufferWalker = buffer;
    4175 
     4186 
    41764187  while ( (size > 0) && (blockIndex != BLOCK_END_OF_CHAIN) )
    41774188  {
     
    41794190     * Calculate how many bytes we can copy from this big block.
    41804191     */
    4181     bytesToReadInBuffer =
     4192    bytesToReadInBuffer = 
    41824193      min(This->parentStorage->bigBlockSize - offsetInBlock, size);
    4183 
     4194   
    41844195    /*
    41854196     * Copy those bytes to the buffer
    41864197     */
    4187     bigBlockBuffer =
     4198    bigBlockBuffer = 
    41884199      StorageImpl_GetROBigBlock(This->parentStorage, blockIndex);
    4189 
     4200   
    41904201    memcpy(bufferWalker, bigBlockBuffer + offsetInBlock, bytesToReadInBuffer);
    4191 
     4202   
    41924203    StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer);
    4193 
     4204   
    41944205    /*
    41954206     * Step to the next big block.
    41964207     */
    4197     blockIndex    =
     4208    blockIndex    = 
    41984209      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    41994210
     
    42044215
    42054216  }
    4206 
     4217 
    42074218  return (size == 0);
    42084219}
     
    42494260  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    42504261  {
    4251     blockIndex =
     4262    blockIndex = 
    42524263      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    4253 
     4264   
    42544265    blockNoInSequence--;
    42554266  }
     
    42694280     * Calculate how many bytes we can copy from this big block.
    42704281     */
    4271     bytesToWrite =
     4282    bytesToWrite = 
    42724283      min(This->parentStorage->bigBlockSize - offsetInBlock, size);
    4273 
     4284   
    42744285    /*
    42754286     * Copy those bytes to the buffer
    42764287     */
    42774288    bigBlockBuffer = StorageImpl_GetBigBlock(This->parentStorage, blockIndex);
    4278 
     4289   
    42794290    memcpy(bigBlockBuffer + offsetInBlock, bufferWalker, bytesToWrite);
    4280 
     4291   
    42814292    StorageImpl_ReleaseBigBlock(This->parentStorage, bigBlockBuffer);
    4282 
     4293   
    42834294    /*
    42844295     * Step to the next big block.
    42854296     */
    4286     blockIndex    =
     4297    blockIndex    = 
    42874298      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    42884299
     
    42924303    offsetInBlock  = 0;      /* There is no offset on the next block */
    42934304  }
    4294 
     4305 
    42954306  return (size == 0);
    42964307}
     
    43294340  while (count < numBlocks)
    43304341  {
    4331     blockIndex =
     4342    blockIndex = 
    43324343      StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    43334344
     
    43364347
    43374348  /* Get the next block before marking the new end */
    4338   extraBlock =
     4349  extraBlock = 
    43394350    StorageImpl_GetNextBlockInChain(This->parentStorage, blockIndex);
    43404351
    43414352  /* Mark the new end of chain */
    43424353  StorageImpl_SetNextBlockInChain(
    4343     This->parentStorage,
    4344     blockIndex,
     4354    This->parentStorage, 
     4355    blockIndex, 
    43454356    BLOCK_END_OF_CHAIN);
    43464357
     
    43534364  while (extraBlock != BLOCK_END_OF_CHAIN)
    43544365  {
    4355     blockIndex =
     4366    blockIndex = 
    43564367      StorageImpl_GetNextBlockInChain(This->parentStorage, extraBlock);
    43574368
     
    43974408
    43984409      StorageImpl_ReadProperty(
    4399         This->parentStorage,
     4410        This->parentStorage, 
    44004411        This->ownerPropertyIndex,
    44014412        &chainProp);
    44024413
    4403       chainProp.startingBlock = blockIndex;
     4414      chainProp.startingBlock = blockIndex; 
    44044415
    44054416      StorageImpl_WriteProperty(
    4406         This->parentStorage,
     4417        This->parentStorage, 
    44074418        This->ownerPropertyIndex,
    44084419        &chainProp);
     
    44534464
    44544465      StorageImpl_SetNextBlockInChain(
    4455     This->parentStorage,
    4456     currentBlock,
    4457     blockIndex);
     4466        This->parentStorage,
     4467        currentBlock,
     4468        blockIndex);
    44584469
    44594470      StorageImpl_SetNextBlockInChain(
    4460         This->parentStorage,
    4461     blockIndex,
    4462     BLOCK_END_OF_CHAIN);
     4471        This->parentStorage, 
     4472        blockIndex,
     4473        BLOCK_END_OF_CHAIN);
    44634474
    44644475      currentBlock = blockIndex;
     
    44814492 * TODO: Free the actual blocks in the file when we shrink the chain.
    44824493 *       Currently, the blocks are still in the file. So the file size
    4483  *       doesn't shrink even if we shrink streams.
     4494 *       doesn't shrink even if we shrink streams. 
    44844495 */
    44854496BOOL BlockChainStream_SetSize(
     
    44984509  else
    44994510  {
    4500     ULARGE_INTEGER fileSize =
     4511    ULARGE_INTEGER fileSize = 
    45014512      BIGBLOCKFILE_GetSize(This->parentStorage->bigBlockFile);
    45024513
     
    45074518     */
    45084519    if ((diff % This->parentStorage->bigBlockSize) != 0)
    4509       diff += (This->parentStorage->bigBlockSize -
     4520      diff += (This->parentStorage->bigBlockSize - 
    45104521                (diff % This->parentStorage->bigBlockSize) );
    45114522
     
    45314542  if(This->headOfStreamPlaceHolder == NULL)
    45324543  {
    4533     /*
    4534      * This chain is a data stream read the property and return
     4544    /* 
     4545     * This chain is a data stream read the property and return 
    45354546     * the appropriate size
    45364547     */
     
    45454556  {
    45464557    /*
    4547      * this chain is a chain that does not have a property, figure out the
    4548      * size by making the product number of used blocks times the
     4558     * this chain is a chain that does not have a property, figure out the 
     4559     * size by making the product number of used blocks times the 
    45494560     * size of them
    45504561     */
     
    45524563    result.s.HighPart = 0;
    45534564
    4554     result.s.LowPart  =
    4555       BlockChainStream_GetCount(This) *
     4565    result.s.LowPart  = 
     4566      BlockChainStream_GetCount(This) * 
    45564567      This->parentStorage->bigBlockSize;
    45574568
     
    45654576
    45664577SmallBlockChainStream* SmallBlockChainStream_Construct(
    4567   StorageImpl* parentStorage,
     4578  StorageImpl* parentStorage, 
    45684579  ULONG          propertyIndex)
    45694580{
     
    46164627 *
    46174628 * Returns the index of the next small block in this chain.
    4618  *
     4629 * 
    46194630 * Return Values:
    46204631 *    - BLOCK_END_OF_CHAIN: end of this chain
     
    47434754    else
    47444755    {
    4745       ULONG count =
     4756      ULONG count = 
    47464757        BlockChainStream_GetCount(This->parentStorage->smallBlockDepotChain);
    47474758
     
    47544765      {
    47554766        sbdIndex = nextBlock;
    4756         nextBlock =
     4767        nextBlock = 
    47574768          StorageImpl_GetNextBlockInChain(This->parentStorage, sbdIndex);
    47584769      }
     
    47614772      if (sbdIndex != BLOCK_END_OF_CHAIN)
    47624773        StorageImpl_SetNextBlockInChain(
    4763           This->parentStorage,
    4764           sbdIndex,
     4774          This->parentStorage, 
     4775          sbdIndex, 
    47654776          newsbdIndex);
    47664777
    47674778      StorageImpl_SetNextBlockInChain(
    4768         This->parentStorage,
    4769         newsbdIndex,
     4779        This->parentStorage, 
     4780        newsbdIndex, 
    47704781        BLOCK_END_OF_CHAIN);
    47714782
     
    47734784       * Initialize all the small blocks to free
    47744785       */
    4775       smallBlockDepot =
     4786      smallBlockDepot = 
    47764787        StorageImpl_GetBigBlock(This->parentStorage, newsbdIndex);
    47774788
     
    47854796         */
    47864797        StgProperty rootProp;
    4787         ULONG sbStartIndex;
     4798        ULONG sbStartIndex; 
    47884799
    47894800        /*
     
    47944805
    47954806        /*
    4796          * And allocate the first big block that will contain small blocks
     4807         * And allocate the first big block that will contain small blocks 
    47974808         */
    4798         sbStartIndex =
     4809        sbStartIndex = 
    47994810          StorageImpl_GetNextFreeBigBlock(This->parentStorage);
    48004811
    48014812        StorageImpl_SetNextBlockInChain(
    4802           This->parentStorage,
    4803           sbStartIndex,
     4813          This->parentStorage, 
     4814          sbStartIndex, 
    48044815          BLOCK_END_OF_CHAIN);
    48054816
    48064817        StorageImpl_ReadProperty(
    4807           This->parentStorage,
    4808           This->parentStorage->rootPropertySetIndex,
     4818          This->parentStorage, 
     4819          This->parentStorage->rootPropertySetIndex, 
    48094820          &rootProp);
    48104821
     
    48144825
    48154826        StorageImpl_WriteProperty(
    4816           This->parentStorage,
    4817           This->parentStorage->rootPropertySetIndex,
     4827          This->parentStorage, 
     4828          This->parentStorage->rootPropertySetIndex, 
    48184829          &rootProp);
    48194830      }
     
    48214832  }
    48224833
    4823   smallBlocksPerBigBlock =
     4834  smallBlocksPerBigBlock = 
    48244835    This->parentStorage->bigBlockSize / This->parentStorage->smallBlockSize;
    48254836
     
    48334844
    48344845    StorageImpl_ReadProperty(
    4835       This->parentStorage,
    4836       This->parentStorage->rootPropertySetIndex,
     4846      This->parentStorage, 
     4847      This->parentStorage->rootPropertySetIndex, 
    48374848      &rootProp);
    48384849
    4839     if (rootProp.size.s.LowPart <
     4850    if (rootProp.size.s.LowPart < 
    48404851       (blocksRequired * This->parentStorage->bigBlockSize))
    48414852    {
     
    48434854
    48444855      BlockChainStream_SetSize(
    4845         This->parentStorage->smallBlockRootChain,
     4856        This->parentStorage->smallBlockRootChain, 
    48464857        rootProp.size);
    48474858
    48484859      StorageImpl_WriteProperty(
    4849         This->parentStorage,
    4850         This->parentStorage->rootPropertySetIndex,
     4860        This->parentStorage, 
     4861        This->parentStorage->rootPropertySetIndex, 
    48514862        &rootProp);
    48524863    }
     
    48614872 * Reads a specified number of bytes from this chain at the specified offset.
    48624873 * bytesRead may be NULL.
    4863  * Failure will be returned if the specified number of bytes has not been read.
     4874 * Failure will be returned if the specified number of bytes has not been read. 
    48644875 */
    48654876BOOL SmallBlockChainStream_ReadAt(
     
    48714882{
    48724883  ULARGE_INTEGER offsetInBigBlockFile;
    4873   ULONG blockNoInSequence =
     4884  ULONG blockNoInSequence = 
    48744885    offset.s.LowPart / This->parentStorage->smallBlockSize;
    48754886
     
    49084919     * Calculate how many bytes we can copy from this small block.
    49094920     */
    4910     bytesToReadInBuffer =
     4921    bytesToReadInBuffer = 
    49114922      min(This->parentStorage->smallBlockSize - offsetInBlock, size);
    49124923
     
    49154926     */
    49164927    offsetInBigBlockFile.s.HighPart  = 0;
    4917     offsetInBigBlockFile.s.LowPart   =
     4928    offsetInBigBlockFile.s.LowPart   = 
    49184929      blockIndex * This->parentStorage->smallBlockSize;
    49194930
     
    49594970{
    49604971  ULARGE_INTEGER offsetInBigBlockFile;
    4961   ULONG blockNoInSequence =
     4972  ULONG blockNoInSequence = 
    49624973    offset.s.LowPart / This->parentStorage->smallBlockSize;
    49634974
     
    49674978  ULONG bytesWrittenFromBigBlockFile;
    49684979  BYTE* bufferWalker;
    4969 
     4980 
    49704981  /*
    49714982   * This should never happen on a small block file.
    49724983   */
    49734984  assert(offset.s.HighPart==0);
    4974 
     4985 
    49754986  /*
    49764987   * Find the first block in the stream that contains part of the buffer.
    49774988   */
    49784989  blockIndex = SmallBlockChainStream_GetHeadOfChain(This);
    4979 
     4990 
    49804991  while ( (blockNoInSequence > 0) &&  (blockIndex != BLOCK_END_OF_CHAIN))
    49814992  {
    49824993    blockIndex = SmallBlockChainStream_GetNextBlockInChain(This, blockIndex);
    4983 
     4994   
    49844995    blockNoInSequence--;
    49854996  }
    4986 
     4997 
    49874998  /*
    49884999   * Start writing the buffer.
     
    49985009     * Calculate how many bytes we can copy to this small block.
    49995010     */
    5000     bytesToWriteInBuffer =
     5011    bytesToWriteInBuffer = 
    50015012      min(This->parentStorage->smallBlockSize - offsetInBlock, size);
    5002 
     5013   
    50035014    /*
    50045015     * Calculate the offset of the small block in the small block file.
    50055016     */
    50065017    offsetInBigBlockFile.s.HighPart  = 0;
    5007     offsetInBigBlockFile.s.LowPart   =
     5018    offsetInBigBlockFile.s.LowPart   = 
    50085019      blockIndex * This->parentStorage->smallBlockSize;
    50095020
    50105021    offsetInBigBlockFile.s.LowPart  += offsetInBlock;
    5011 
     5022   
    50125023    /*
    50135024     * Write those bytes in the buffer to the small block file.
     
    50185029      bufferWalker,
    50195030      &bytesWrittenFromBigBlockFile);
    5020 
     5031   
    50215032    assert(bytesWrittenFromBigBlockFile == bytesToWriteInBuffer);
    5022 
     5033   
    50235034    /*
    50245035     * Step to the next big block.
     
    50305041    offsetInBlock  = 0;     /* There is no offset on the next block */
    50315042  }
    5032 
     5043 
    50335044  return (size == 0);
    50345045}
     
    50375048 *       SmallBlockChainStream_Shrink
    50385049 *
    5039  * Shrinks this chain in the small block depot.
     5050 * Shrinks this chain in the small block depot. 
    50405051 */
    50415052BOOL SmallBlockChainStream_Shrink(
     
    50655076  /*
    50665077   * If the count is 0, we have a special case, the head of the chain was
    5067    * just freed.
     5078   * just freed. 
    50685079   */
    50695080  if (count == 0)
     
    50715082    StgProperty chainProp;
    50725083
    5073     StorageImpl_ReadProperty(This->parentStorage,
    5074                  This->ownerPropertyIndex,
    5075                  &chainProp);
     5084    StorageImpl_ReadProperty(This->parentStorage, 
     5085                             This->ownerPropertyIndex,
     5086                             &chainProp);
    50765087
    50775088    chainProp.startingBlock = BLOCK_END_OF_CHAIN;
    50785089
    50795090    StorageImpl_WriteProperty(This->parentStorage,
    5080                   This->ownerPropertyIndex,
    5081                   &chainProp);
     5091                              This->ownerPropertyIndex,
     5092                              &chainProp);
    50825093
    50835094    /*
     
    50935104    /* Mark the new end of chain */
    50945105    SmallBlockChainStream_SetNextBlockInChain(
    5095       This,
    5096       blockIndex,
     5106      This, 
     5107      blockIndex, 
    50975108      BLOCK_END_OF_CHAIN);
    50985109  }
     
    51085119  }
    51095120
    5110   return TRUE;
     5121  return TRUE; 
    51115122}
    51125123
     
    51445155    blockIndex = chainProp.startingBlock;
    51455156    SmallBlockChainStream_SetNextBlockInChain(
    5146       This,
    5147       blockIndex,
     5157      This, 
     5158      blockIndex, 
    51485159      BLOCK_END_OF_CHAIN);
    51495160  }
     
    51785189
    51795190    SmallBlockChainStream_SetNextBlockInChain(
    5180       This,
    5181       blockIndex,
     5191      This, 
     5192      blockIndex, 
    51825193      BLOCK_END_OF_CHAIN);
    51835194
     
    52205231 * TODO: Free the actual blocks in the file when we shrink the chain.
    52215232 *       Currently, the blocks are still in the file. So the file size
    5222  *       doesn't shrink even if we shrink streams.
     5233 *       doesn't shrink even if we shrink streams. 
    52235234 */
    52245235BOOL SmallBlockChainStream_SetSize(
     
    52785289  WCHAR          tempFileName[MAX_PATH];
    52795290
    5280   TRACE("(%s, %lx, %ld, %p)\n",
    5281     debugstr_w(pwcsName), grfMode,
    5282     reserved, ppstgOpen);
     5291  TRACE("(%s, %lx, %ld, %p)\n", 
     5292        debugstr_w(pwcsName), grfMode,
     5293        reserved, ppstgOpen);
    52835294
    52845295  /*
     
    53265337
    53275338  /*
    5328    * Interpret the STGM value grfMode
     5339   * Interpret the STGM value grfMode 
    53295340   */
    53305341  shareMode    = GetShareModeFromSTGM(grfMode);
     
    53515362                        fileAttributes,
    53525363            0);
    5353 
     5364 
    53545365  if (hFile == INVALID_HANDLE_VALUE)
    53555366  {
     
    53615372   */
    53625373  newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
    5363 
     5374 
    53645375  if (newStorage == 0)
    53655376    return STG_E_INSUFFICIENTMEMORY;
     
    53725383         TRUE,
    53735384         TRUE);
    5374 
     5385 
    53755386  if (FAILED(hr))
    53765387  {
     
    53985409  DWORD           grfMode,
    53995410  SNB           snbExclude,
    5400   DWORD           reserved,
     5411  DWORD           reserved, 
    54015412  IStorage      **ppstgOpen)
    54025413{
     
    54075418  DWORD          accessMode;
    54085419
    5409   TRACE("(%s, %p, %lx, %p, %ld, %p)\n",
    5410     debugstr_w(pwcsName), pstgPriority, grfMode,
    5411     snbExclude, reserved, ppstgOpen);
     5420  TRACE("(%s, %p, %lx, %p, %ld, %p)\n", 
     5421        debugstr_w(pwcsName), pstgPriority, grfMode,
     5422        snbExclude, reserved, ppstgOpen);
    54125423
    54135424  /*
     
    54335444   */
    54345445  *ppstgOpen = 0;
    5435 
    5436   hFile = CreateFileW( pwcsName,
     5446 
     5447  hFile = CreateFileW( pwcsName, 
    54375448                       accessMode,
    54385449                       shareMode,
     
    54415452                       FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS,
    54425453                       0);
    5443 
    5444 
     5454 
     5455 
    54455456  if (hFile==INVALID_HANDLE_VALUE)
    54465457  {
     
    54785489   */
    54795490  newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
    5480 
     5491 
    54815492  if (newStorage == 0)
    54825493    return STG_E_INSUFFICIENTMEMORY;
     
    54895500         TRUE,
    54905501         FALSE);
    5491 
     5502 
    54925503  if (FAILED(hr))
    54935504  {
     
    54975508     */
    54985509    if(hr == STG_E_INVALIDHEADER)
    5499     return STG_E_FILEALREADYEXISTS;
     5510        return STG_E_FILEALREADYEXISTS;
    55005511    return hr;
    55015512  }
    5502 
     5513 
    55035514  /*
    55045515   * Get an "out" pointer for the caller.
     
    55085519         (REFIID)&IID_IStorage,
    55095520         (void**)ppstgOpen);
    5510 
     5521 
    55115522  return hr;
    55125523}
     
    55605571         (void**)ppstgOpen);
    55615572
    5562   return hr;
     5573  return hr; 
    55635574}
    55645575
     
    55985609   */
    55995610  newStorage = HeapAlloc(GetProcessHeap(), 0, sizeof(StorageImpl));
    5600 
     5611 
    56015612  if (newStorage == 0)
    56025613    return STG_E_INSUFFICIENTMEMORY;
     
    56345645HRESULT WINAPI StgSetTimes(WCHAR * str, FILETIME * a, FILETIME * b, FILETIME *c )
    56355646{
    5636 
     5647 
    56375648  FIXME("(%p, %p, %p, %p),stub!\n", str, a, b, c);
    56385649  return FALSE;
     
    56855696    STATSTG pstatstg;
    56865697    HRESULT hRes;
    5687 
     5698   
    56885699    TRACE("()\n");
    56895700
     
    57085719HRESULT  WINAPI OleLoadFromStream(IStream *pStm,REFIID iidInterface,void** ppvObj)
    57095720{
    5710     CLSID   clsid;
    5711     HRESULT res;
    5712     LPPERSISTSTREAM xstm;
     5721    CLSID       clsid;
     5722    HRESULT     res;
     5723    LPPERSISTSTREAM     xstm;
    57135724
    57145725    TRACE("(%p,%s,%p)\n",pStm,debugstr_guid(iidInterface),ppvObj);
     
    57165727    res=ReadClassStm(pStm,&clsid);
    57175728    if (!SUCCEEDED(res))
    5718     return res;
     5729        return res;
    57195730    res=CoCreateInstance(&clsid,NULL,CLSCTX_INPROC_SERVER,iidInterface,ppvObj);
    57205731    if (!SUCCEEDED(res))
    5721     return res;
     5732        return res;
    57225733    res=IUnknown_QueryInterface((IUnknown*)*ppvObj,&IID_IPersistStream,(LPVOID*)&xstm);
    57235734    if (!SUCCEEDED(res)) {
    5724     IUnknown_Release((IUnknown*)*ppvObj);
    5725     return res;
     5735        IUnknown_Release((IUnknown*)*ppvObj);
     5736        return res;
    57265737    }
    57275738    res=IPersistStream_Load(xstm,pStm);
    57285739    IPersistStream_Release(xstm);
    57295740    /* FIXME: all refcounts ok at this point? I think they should be:
    5730      *      pStm    : unchanged
    5731      *      ppvObj  : 1
    5732      *      xstm    : 0 (released)
     5741     *          pStm    : unchanged
     5742     *          ppvObj  : 1
     5743     *          xstm    : 0 (released)
    57335744     */
    57345745    return res;
     
    57465757    CLSID clsid;
    57475758    HRESULT res;
    5748 
     5759   
    57495760    TRACE("(%p,%p)\n",pPStm,pStm);
    57505761
     
    57525763
    57535764    if (SUCCEEDED(res)){
    5754 
     5765       
    57555766        res=WriteClassStm(pStm,&clsid);
    57565767
     
    57705781 * STGM_TRANSACTED           0x00010000
    57715782 * STGM_SIMPLE               0x08000000
    5772  *
     5783 * 
    57735784 * STGM_READ                 0x00000000
    57745785 * STGM_WRITE                0x00000001
    57755786 * STGM_READWRITE            0x00000002
    5776  *
     5787 * 
    57775788 * STGM_SHARE_DENY_NONE      0x00000040
    57785789 * STGM_SHARE_DENY_READ      0x00000030
    57795790 * STGM_SHARE_DENY_WRITE     0x00000020
    57805791 * STGM_SHARE_EXCLUSIVE      0x00000010
    5781  *
     5792 * 
    57825793 * STGM_PRIORITY             0x00040000
    57835794 * STGM_DELETEONRELEASE      0x04000000
     
    57955806  BOOL bSTGM_SIMPLE           = ((stgm & STGM_SIMPLE) == STGM_SIMPLE);
    57965807  BOOL bSTGM_DIRECT           = ! (bSTGM_TRANSACTED || bSTGM_SIMPLE);
    5797 
     5808   
    57985809  BOOL bSTGM_WRITE            = ((stgm & STGM_WRITE) == STGM_WRITE);
    57995810  BOOL bSTGM_READWRITE        = ((stgm & STGM_READWRITE) == STGM_READWRITE);
    58005811  BOOL bSTGM_READ             = ! (bSTGM_WRITE || bSTGM_READWRITE);
    5801 
     5812   
    58025813  BOOL bSTGM_SHARE_DENY_NONE  =
    58035814                     ((stgm & STGM_SHARE_DENY_NONE)  == STGM_SHARE_DENY_NONE);
     
    58145825  BOOL bSTGM_CREATE           = ((stgm & STGM_CREATE) == STGM_CREATE);
    58155826  BOOL bSTGM_CONVERT          = ((stgm & STGM_CONVERT) == STGM_CONVERT);
    5816 
     5827   
    58175828  BOOL bSTGM_NOSCRATCH        = ((stgm & STGM_NOSCRATCH) == STGM_NOSCRATCH);
    58185829  BOOL bSTGM_NOSNAPSHOT       = ((stgm & STGM_NOSNAPSHOT) == STGM_NOSNAPSHOT);
    58195830
    5820   /*
     5831  /* 
    58215832   * STGM_DIRECT | STGM_TRANSACTED | STGM_SIMPLE
    58225833   */
     
    58255836      return E_FAIL;
    58265837
    5827   /*
     5838  /* 
    58285839   * STGM_WRITE |  STGM_READWRITE | STGM_READ
    58295840   */
     
    58335844
    58345845  /*
    5835    * STGM_SHARE_DENY_NONE | others
     5846   * STGM_SHARE_DENY_NONE | others 
    58365847   * (I assume here that DENY_READ implies DENY_WRITE)
    58375848   */
    58385849  if ( bSTGM_SHARE_DENY_NONE )
    58395850    if ( bSTGM_SHARE_DENY_READ ||
    5840          bSTGM_SHARE_DENY_WRITE ||
    5841          bSTGM_SHARE_EXCLUSIVE)
     5851         bSTGM_SHARE_DENY_WRITE || 
     5852         bSTGM_SHARE_EXCLUSIVE) 
    58425853      return E_FAIL;
    58435854
     
    58545865  if ( bSTGM_NOSCRATCH && ! bSTGM_TRANSACTED )
    58555866    return E_FAIL;
    5856 
    5857   /*
    5858    * STGM_NOSNAPSHOT requires STGM_TRANSACTED and
     5867 
     5868  /*
     5869   * STGM_NOSNAPSHOT requires STGM_TRANSACTED and 
    58595870   * not STGM_SHARE_EXCLUSIVE or STGM_SHARE_DENY_WRITE`
    58605871   */
    58615872  if (bSTGM_NOSNAPSHOT)
    58625873  {
    5863     if ( ! ( bSTGM_TRANSACTED &&
     5874    if ( ! ( bSTGM_TRANSACTED && 
    58645875           !(bSTGM_SHARE_EXCLUSIVE || bSTGM_SHARE_DENY_WRITE)) )
    58655876    return E_FAIL;
     
    58735884 *
    58745885 * This method will return a share mode flag from a STGM value.
    5875  * The STGM value is assumed valid.
     5886 * The STGM value is assumed valid. 
    58765887 */
    58775888static DWORD GetShareModeFromSTGM(DWORD stgm)
     
    59435954  /* All other cases */
    59445955  if (stgm & ~ (STGM_CREATE|STGM_CONVERT))
    5945     FIXME("unhandled storage mode : 0x%08lx\n",stgm & ~ (STGM_CREATE|STGM_CONVERT));
     5956        FIXME("unhandled storage mode : 0x%08lx\n",stgm & ~ (STGM_CREATE|STGM_CONVERT));
    59465957  return CREATE_NEW;
    59475958}
     
    59495960
    59505961/*************************************************************************
    5951  * OLECONVERT_LoadOLE10 [Internal]
    5952  *
    5953  * Loads the OLE10 STREAM to memory
     5962 * OLECONVERT_LoadOLE10 [Internal] 
     5963 *
     5964 * Loads the OLE10 STREAM to memory 
    59545965 *
    59555966 * PARAMS
     
    59645975 * NOTES
    59655976 *     This function is used by OleConvertOLESTREAMToIStorage only.
    5966  *
     5977 *     
    59675978 *     Memory allocated for pData must be freed by the caller
    59685979 */
    59695980HRESULT OLECONVERT_LoadOLE10(LPOLESTREAM pOleStream, OLECONVERT_OLESTREAM_DATA *pData, BOOL bStrem1)
    59705981{
    5971     DWORD dwSize;
    5972     HRESULT hRes = S_OK;
    5973     int nTryCnt=0;
    5974     int max_try = 6;
    5975 
    5976     pData->pData = NULL;
    5977     pData->pstrOleObjFileName = (CHAR *) NULL;
    5978 
    5979     for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)
    5980     {
    5981     /* Get the OleID */
    5982     dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
    5983     if(dwSize != sizeof(pData->dwOleID))
    5984     {
    5985         hRes = CONVERT10_E_OLESTREAM_GET;
    5986     }
    5987     else if(pData->dwOleID != OLESTREAM_ID)
    5988     {
    5989         hRes = CONVERT10_E_OLESTREAM_FMT;
    5990     }
    5991         else
    5992         {
    5993             hRes = S_OK;
    5994             break;
    5995         }
    5996     }
    5997 
    5998     if(hRes == S_OK)
    5999     {
    6000         /* Get the TypeID...more info needed for this field */
    6001         dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
    6002         if(dwSize != sizeof(pData->dwTypeID))
    6003         {
    6004             hRes = CONVERT10_E_OLESTREAM_GET;
    6005         }
    6006     }
    6007     if(hRes == S_OK)
    6008     {
    6009         if(pData->dwTypeID != 0)
    6010         {
    6011             /* Get the lenght of the OleTypeName */
    6012             dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
    6013             if(dwSize != sizeof(pData->dwOleTypeNameLength))
    6014             {
    6015                 hRes = CONVERT10_E_OLESTREAM_GET;
    6016             }
    6017 
    6018             if(hRes == S_OK)
    6019             {
    6020                 if(pData->dwOleTypeNameLength > 0)
    6021                 {
    6022                     /* Get the OleTypeName */
    6023                     dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->strOleTypeName, pData->dwOleTypeNameLength);
    6024                     if(dwSize != pData->dwOleTypeNameLength)
    6025                     {
    6026                         hRes = CONVERT10_E_OLESTREAM_GET;
    6027                     }
    6028                 }
    6029             }
    6030             if(bStrem1)
    6031             {
    6032                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));
    6033                 if(dwSize != sizeof(pData->dwOleObjFileNameLength))
    6034                 {
    6035                     hRes = CONVERT10_E_OLESTREAM_GET;
    6036                 }
    6037             if(hRes == S_OK)
    6038             {
    6039                     if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */
    6040                         pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);
    6041                     pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength);
    6042                     if(pData->pstrOleObjFileName)
    6043                     {
    6044                         dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength);
    6045                         if(dwSize != pData->dwOleObjFileNameLength)
    6046                         {
    6047                             hRes = CONVERT10_E_OLESTREAM_GET;
    6048                         }
    6049                     }
    6050                     else
    6051                         hRes = CONVERT10_E_OLESTREAM_GET;
    6052                 }
    6053             }
    6054             else
    6055             {
    6056                 /* Get the Width of the Metafile */
    6057                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
    6058                 if(dwSize != sizeof(pData->dwMetaFileWidth))
    6059                 {
    6060                     hRes = CONVERT10_E_OLESTREAM_GET;
    6061                 }
    6062             if(hRes == S_OK)
    6063             {
    6064                 /* Get the Height of the Metafile */
    6065                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
    6066                 if(dwSize != sizeof(pData->dwMetaFileHeight))
    6067                 {
    6068                     hRes = CONVERT10_E_OLESTREAM_GET;
    6069                 }
    6070             }
    6071             }
    6072             if(hRes == S_OK)
    6073             {
    6074                 /* Get the Lenght of the Data */
    6075                 dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
    6076                 if(dwSize != sizeof(pData->dwDataLength))
    6077                 {
    6078                     hRes = CONVERT10_E_OLESTREAM_GET;
    6079                 }
    6080             }
    6081 
    6082             if(hRes == S_OK) /* I don't know what is this 8 byts information is we have to figure out */
    6083             {
    6084                 if(!bStrem1) /* if it is a second OLE stream data */
    6085                 {
    6086                     pData->dwDataLength -= 8;
    6087                     dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown));
    6088                     if(dwSize != sizeof(pData->strUnknown))
    6089                     {
    6090                         hRes = CONVERT10_E_OLESTREAM_GET;
    6091                     }
    6092                 }
    6093             }
    6094             if(hRes == S_OK)
    6095             {
    6096                 if(pData->dwDataLength > 0)
    6097                 {
    6098                     pData->pData = (BYTE *)HeapAlloc(GetProcessHeap(),0,pData->dwDataLength);
    6099 
    6100                     /* Get Data (ex. IStorage, Metafile, or BMP) */
    6101                     if(pData->pData)
    6102                     {
    6103                         dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength);
    6104                         if(dwSize != pData->dwDataLength)
    6105                         {
    6106                             hRes = CONVERT10_E_OLESTREAM_GET;
    6107                         }
    6108                     }
    6109                     else
    6110                     {
    6111                         hRes = CONVERT10_E_OLESTREAM_GET;
    6112                     }
    6113                 }
    6114             }
    6115         }
    6116     }
    6117     return hRes;
     5982        DWORD dwSize;
     5983        HRESULT hRes = S_OK;
     5984        int nTryCnt=0;
     5985        int max_try = 6;
     5986
     5987        pData->pData = NULL;
     5988        pData->pstrOleObjFileName = (CHAR *) NULL;
     5989
     5990        for( nTryCnt=0;nTryCnt < max_try; nTryCnt++)
     5991        {
     5992        /* Get the OleID */
     5993        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleID), sizeof(pData->dwOleID));
     5994        if(dwSize != sizeof(pData->dwOleID))
     5995        {
     5996                hRes = CONVERT10_E_OLESTREAM_GET;
     5997        }
     5998        else if(pData->dwOleID != OLESTREAM_ID)
     5999        {
     6000                hRes = CONVERT10_E_OLESTREAM_FMT;
     6001        }
     6002                else
     6003                {
     6004                        hRes = S_OK;
     6005                        break;
     6006                }
     6007        }
     6008
     6009        if(hRes == S_OK)
     6010        {
     6011                /* Get the TypeID...more info needed for this field */
     6012                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwTypeID), sizeof(pData->dwTypeID));
     6013                if(dwSize != sizeof(pData->dwTypeID))
     6014                {
     6015                        hRes = CONVERT10_E_OLESTREAM_GET;
     6016                }
     6017        }
     6018        if(hRes == S_OK)
     6019        {
     6020                if(pData->dwTypeID != 0)
     6021                {
     6022                        /* Get the lenght of the OleTypeName */
     6023                        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *) &(pData->dwOleTypeNameLength), sizeof(pData->dwOleTypeNameLength));
     6024                        if(dwSize != sizeof(pData->dwOleTypeNameLength))
     6025                        {
     6026                                hRes = CONVERT10_E_OLESTREAM_GET;
     6027                        }
     6028
     6029                        if(hRes == S_OK)
     6030                        {
     6031                                if(pData->dwOleTypeNameLength > 0)
     6032                                {
     6033                                        /* Get the OleTypeName */
     6034                                        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->strOleTypeName, pData->dwOleTypeNameLength);
     6035                                        if(dwSize != pData->dwOleTypeNameLength)
     6036                                        {
     6037                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6038                                        }
     6039                                }
     6040                        }
     6041                        if(bStrem1)
     6042                        {
     6043                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwOleObjFileNameLength), sizeof(pData->dwOleObjFileNameLength));
     6044                                if(dwSize != sizeof(pData->dwOleObjFileNameLength))
     6045                                {
     6046                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6047                                }
     6048                        if(hRes == S_OK)
     6049                        {
     6050                                        if(pData->dwOleObjFileNameLength < 1) /* there is no file name exist */
     6051                                                pData->dwOleObjFileNameLength = sizeof(pData->dwOleObjFileNameLength);
     6052                                        pData->pstrOleObjFileName = (CHAR *)malloc(pData->dwOleObjFileNameLength);
     6053                                        if(pData->pstrOleObjFileName)
     6054                                        {
     6055                                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->pstrOleObjFileName),pData->dwOleObjFileNameLength);
     6056                                                if(dwSize != pData->dwOleObjFileNameLength)
     6057                                                {
     6058                                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6059                                                }
     6060                                        }
     6061                                        else
     6062                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6063                                }
     6064                        }
     6065                        else
     6066                        {
     6067                                /* Get the Width of the Metafile */
     6068                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileWidth), sizeof(pData->dwMetaFileWidth));
     6069                                if(dwSize != sizeof(pData->dwMetaFileWidth))
     6070                                {
     6071                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6072                                }
     6073                        if(hRes == S_OK)
     6074                        {
     6075                                /* Get the Height of the Metafile */
     6076                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwMetaFileHeight), sizeof(pData->dwMetaFileHeight));
     6077                                if(dwSize != sizeof(pData->dwMetaFileHeight))
     6078                                {
     6079                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6080                                }
     6081                        }
     6082                        }
     6083                        if(hRes == S_OK)
     6084                        {
     6085                                /* Get the Lenght of the Data */
     6086                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)&(pData->dwDataLength), sizeof(pData->dwDataLength));
     6087                                if(dwSize != sizeof(pData->dwDataLength))
     6088                                {
     6089                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6090                                }
     6091                        }
     6092
     6093                        if(hRes == S_OK) /* I don't know what is this 8 byts information is we have to figure out */
     6094                        {
     6095                                if(!bStrem1) /* if it is a second OLE stream data */
     6096                                {
     6097                                        pData->dwDataLength -= 8;
     6098                                        dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)(pData->strUnknown), sizeof(pData->strUnknown));
     6099                                        if(dwSize != sizeof(pData->strUnknown))
     6100                                        {
     6101                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6102                                        }
     6103                                }
     6104                        }
     6105                        if(hRes == S_OK)
     6106                        {
     6107                                if(pData->dwDataLength > 0)
     6108                                {
     6109                                        pData->pData = (BYTE *)HeapAlloc(GetProcessHeap(),0,pData->dwDataLength);
     6110
     6111                                        /* Get Data (ex. IStorage, Metafile, or BMP) */
     6112                                        if(pData->pData)
     6113                                        {
     6114                                                dwSize = pOleStream->lpstbl->Get(pOleStream, (void *)pData->pData, pData->dwDataLength);
     6115                                                if(dwSize != pData->dwDataLength)
     6116                                                {
     6117                                                        hRes = CONVERT10_E_OLESTREAM_GET;
     6118                                                }
     6119                                        }
     6120                                        else
     6121                                        {
     6122                                                hRes = CONVERT10_E_OLESTREAM_GET;
     6123                                        }
     6124                                }
     6125                        }
     6126                }
     6127        }
     6128        return hRes;
    61186129}
    61196130
    61206131/*************************************************************************
    6121  * OLECONVERT_SaveOLE10 [Internal]
    6122  *
    6123  * Saves the OLE10 STREAM From memory
     6132 * OLECONVERT_SaveOLE10 [Internal] 
     6133 *
     6134 * Saves the OLE10 STREAM From memory 
    61246135 *
    61256136 * PARAMS
     
    61336144 * NOTES
    61346145 *     This function is used by OleConvertIStorageToOLESTREAM only.
    6135  *
     6146 *     
    61366147 */
    61376148HRESULT OLECONVERT_SaveOLE10(OLECONVERT_OLESTREAM_DATA *pData, LPOLESTREAM pOleStream)
     
    62276238
    62286239/*************************************************************************
    6229  * OLECONVERT_GetOLE20FromOLE10[Internal]
     6240 * OLECONVERT_GetOLE20FromOLE10[Internal] 
    62306241 *
    62316242 * This function copies OLE10 Data (the IStorage in the OLESTREAM) to disk,
    6232  * opens it, and copies the content to the dest IStorage for
     6243 * opens it, and copies the content to the dest IStorage for 
    62336244 * OleConvertOLESTREAMToIStorage
    6234  *
     6245 * 
    62356246 *
    62366247 * PARAMS
     
    62436254 *
    62446255 * NOTES
    6245  *
    6246  *
     6256 *     
     6257 *     
    62476258 */
    62486259void OLECONVERT_GetOLE20FromOLE10(LPSTORAGE pDestStorage, BYTE *pBuffer, DWORD nBufferLength)
     
    62796290
    62806291/*************************************************************************
    6281  * OLECONVERT_WriteOLE20ToBuffer [Internal]
    6282  *
    6283  * Saves the OLE10 STREAM From memory
     6292 * OLECONVERT_WriteOLE20ToBuffer [Internal] 
     6293 *
     6294 * Saves the OLE10 STREAM From memory 
    62846295 *
    62856296 * PARAMS
     
    62946305 *
    62956306 *     Used by OleConvertIStorageToOLESTREAM only.
    6296  *
     6307 *     
    62976308 */
    62986309DWORD OLECONVERT_WriteOLE20ToBuffer(LPSTORAGE pStorage, BYTE **pData)
     
    63066317
    63076318    *pData = NULL;
    6308 
     6319   
    63096320    /* Create temp Storage */
    63106321    GetTempPathW(MAX_PATH, wstrTempDir);
     
    63336344
    63346345/*************************************************************************
    6335  * OLECONVERT_CreateOleStream [Internal]
     6346 * OLECONVERT_CreateOleStream [Internal] 
    63366347 *
    63376348 * Creates the "\001OLE" stream in the IStorage if neccessary.
     
    63486359 *     This stream is still unknown, MS Word seems to have extra data
    63496360 *     but since the data is stored in the OLESTREAM there should be
    6350  *     no need to recreate the stream.  If the stream is manually
     6361 *     no need to recreate the stream.  If the stream is manually 
    63516362 *     deleted it will create it with this default data.
    6352  *
     6363 *     
    63536364 */
    63546365void OLECONVERT_CreateOleStream(LPSTORAGE pStorage)
     
    63576368    IStream *pStream;
    63586369    WCHAR wstrStreamName[] = {1,'O', 'l', 'e', 0};
    6359     BYTE pOleStreamHeader [] =
    6360     {
    6361         0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00,
    6362         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    6363         0x00, 0x00, 0x00, 0x00
     6370    BYTE pOleStreamHeader [] = 
     6371    {
     6372        0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 
     6373        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 
     6374        0x00, 0x00, 0x00, 0x00 
    63646375    };
    6365 
     6376   
    63666377    /* Create stream if not present */
    6367     hRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6378    hRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    63686379        STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    63696380
     
    63786389
    63796390/*************************************************************************
    6380  * OLECONVERT_CreateCompObjStream [Internal]
     6391 * OLECONVERT_CreateCompObjStream [Internal] 
    63816392 *
    63826393 * Creates a "\001CompObj" is the destination IStorage if necessary.
    63836394 *
    63846395 * PARAMS
    6385  *     pStorage       [I] The dest IStorage to create the CompObj Stream
     6396 *     pStorage       [I] The dest IStorage to create the CompObj Stream 
    63866397 *                        if necessary.
    63876398 *     strOleTypeName [I] The ProgID
     
    63956406 *
    63966407 *     The stream data is stored in the OLESTREAM and there should be
    6397  *     no need to recreate the stream.  If the stream is manually
     6408 *     no need to recreate the stream.  If the stream is manually 
    63986409 *     deleted it will attempt to create it by querying the registry.
    63996410 *
    6400  *
     6411 *     
    64016412 */
    64026413HRESULT OLECONVERT_CreateCompObjStream(LPSTORAGE pStorage, LPCSTR strOleTypeName)
     
    64176428
    64186429    /*  Create a CompObj stream if it doesn't exist */
    6419     hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6430    hStorageRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    64206431        STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    64216432    if(hStorageRes == S_OK)
     
    64386449            LONG hErr;
    64396450            /* Get the CLSID Default Name from the Registry */
    6440             hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey);
     6451            hErr = RegOpenKeyA(HKEY_CLASSES_ROOT, IStorageCompObj.strProgIDName, &hKey); 
    64416452            if(hErr == ERROR_SUCCESS)
    64426453            {
     
    64806491
    64816492/*************************************************************************
    6482  * OLECONVERT_CreateOlePresStream[Internal]
     6493 * OLECONVERT_CreateOlePresStream[Internal] 
    64836494 *
    64846495 * Creates the "\002OlePres000" Stream with the Metafile data
     
    64876498 *     pStorage     [I] The dest IStorage to create \002OLEPres000 stream in.
    64886499 *     dwExtentX    [I] Width of the Metafile
    6489  *     dwExtentY    [I] Height of the Metafile
     6500 *     dwExtentY    [I] Height of the Metafile 
    64906501 *     pData        [I] Metafile data
    64916502 *     dwDataLength [I] Size of the Metafile data
     
    64976508 * NOTES
    64986509 *     This function is used by OleConvertOLESTREAMToIStorage only.
    6499  *
     6510 *     
    65006511 */
    65016512void OLECONVERT_CreateOlePresStream(LPSTORAGE pStorage, DWORD dwExtentX, DWORD dwExtentY , BYTE *pData, DWORD dwDataLength)
     
    65046515    IStream *pStream;
    65056516    WCHAR wstrStreamName[] = {2, 'O', 'l', 'e', 'P', 'r', 'e', 's', '0', '0', '0', 0};
    6506     BYTE pOlePresStreamHeader [] =
    6507     {
    6508         0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00,
    6509         0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
     6517    BYTE pOlePresStreamHeader [] = 
     6518    {
     6519        0xFF, 0xFF, 0xFF, 0xFF, 0x03, 0x00, 0x00, 0x00, 
     6520        0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
    65106521        0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
    65116522        0x00, 0x00, 0x00, 0x00
    65126523    };
    65136524
    6514     BYTE pOlePresStreamHeaderEmpty [] =
    6515     {
    6516         0x00, 0x00, 0x00, 0x00,
    6517         0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
     6525    BYTE pOlePresStreamHeaderEmpty [] = 
     6526    {
     6527        0x00, 0x00, 0x00, 0x00, 
     6528        0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 
    65186529        0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
    65196530        0x00, 0x00, 0x00, 0x00
    65206531    };
    6521 
     6532     
    65226533    /* Create the OlePres000 Stream */
    6523     hRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6534    hRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    65246535        STGM_CREATE | STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    65256536
     
    65656576
    65666577/*************************************************************************
    6567  * OLECONVERT_CreateOle10NativeStream [Internal]
     6578 * OLECONVERT_CreateOle10NativeStream [Internal] 
    65686579 *
    65696580 * Creates the "\001Ole10Native" Stream (should contain a BMP)
     
    65816592 *
    65826593 *     Might need to verify the data and return appropriate error message
    6583  *
     6594 *     
    65846595 */
    65856596void OLECONVERT_CreateOle10NativeStream(LPSTORAGE pStorage, BYTE *pData, DWORD dwDataLength)
     
    65886599    IStream *pStream;
    65896600    WCHAR wstrStreamName[] = {1, 'O', 'l', 'e', '1', '0', 'N', 'a', 't', 'i', 'v', 'e', 0};
    6590 
     6601   
    65916602    /* Create the Ole10Native Stream */
    6592     hRes = IStorage_CreateStream(pStorage, wstrStreamName,
     6603    hRes = IStorage_CreateStream(pStorage, wstrStreamName, 
    65936604        STGM_CREATE | STGM_WRITE  | STGM_SHARE_EXCLUSIVE, 0, 0, &pStream );
    65946605
     
    66046615
    66056616/*************************************************************************
    6606  * OLECONVERT_GetOLE10ProgID [Internal]
     6617 * OLECONVERT_GetOLE10ProgID [Internal] 
    66076618 *
    66086619 * Finds the ProgID (or OleTypeID) from the IStorage
     
    66206631 *     This function is used by OleConvertIStorageToOLESTREAM only.
    66216632 *
    6622  *
     6633 *     
    66236634 */
    66246635HRESULT OLECONVERT_GetOLE10ProgID(LPSTORAGE pStorage, char *strProgID, DWORD *dwSize)
     
    66316642
    66326643    /* Open the CompObj Stream */
    6633     hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
     6644    hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 
    66346645        STGM_READ  | STGM_SHARE_EXCLUSIVE, 0, &pStream );
    66356646    if(hRes == S_OK)
     
    66686679            *dwSize = WideCharToMultiByte(CP_ACP, 0, wstrProgID, -1, strProgID, *dwSize, NULL, FALSE);
    66696680        }
    6670 
     6681 
    66716682    }
    66726683    return hRes;
     
    66746685
    66756686/*************************************************************************
    6676  * OLECONVERT_GetOle10PresData [Internal]
     6687 * OLECONVERT_GetOle10PresData [Internal] 
    66776688 *
    66786689 * Converts IStorage "/001Ole10Native" stream to a OLE10 Stream
     
    66896700 *
    66906701 *     Memory allocated for pData must be freed by the caller
    6691  *
    6692  *
     6702 *     
     6703 *     
    66936704 */
    66946705void OLECONVERT_GetOle10PresData(LPSTORAGE pStorage, OLECONVERT_OLESTREAM_DATA *pOleStreamData)
     
    67106721
    67116722    /* Open Ole10Native Stream */
    6712     hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
     6723    hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 
    67136724        STGM_READ  | STGM_SHARE_EXCLUSIVE, 0, &pStream );
    67146725    if(hRes == S_OK)
     
    67296740
    67306741/*************************************************************************
    6731  * OLECONVERT_GetOle20PresData[Internal]
     6742 * OLECONVERT_GetOle20PresData[Internal] 
    67326743 *
    67336744 * Converts IStorage "/002OlePres000" stream to a OLE10 Stream
     
    67426753 * NOTES
    67436754 *     This function is used by OleConvertIStorageToOLESTREAM only.
    6744  *
     6755 *     
    67456756 *     Memory allocated for pData must be freed by the caller
    67466757 */
     
    67696780
    67706781    /* Open OlePress000 stream */
    6771     hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL,
     6782    hRes = IStorage_OpenStream(pStorage, wstrStreamName, NULL, 
    67726783        STGM_READ  | STGM_SHARE_EXCLUSIVE, 0, &pStream );
    67736784    if(hRes == S_OK)
     
    68176828
    68186829/*************************************************************************
    6819  * OleConvertOLESTREAMToIStorage [OLE32.87]
     6830 * OleConvertOLESTREAMToIStorage [OLE32.87] 
    68206831 *
    68216832 * Read info on MSDN
     
    68266837 *      Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj",
    68276838 *      and "\001OLE" streams
    6828  *
     6839 *     
    68296840 */
    68306841HRESULT WINAPI OleConvertOLESTREAMToIStorage (
    6831     LPOLESTREAM pOleStream,
    6832     LPSTORAGE pstg,
     6842    LPOLESTREAM pOleStream, 
     6843    LPSTORAGE pstg, 
    68336844    const DVTARGETDEVICE* ptd)
    68346845{
     
    69026913        }
    69036914        if(pOleStreamData[i].pstrOleObjFileName != NULL)
    6904     {
    6905             HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName);
    6906             pOleStreamData[i].pstrOleObjFileName = NULL;
    6907     }
     6915        {
     6916                HeapFree(GetProcessHeap(),0,pOleStreamData[i].pstrOleObjFileName);
     6917                pOleStreamData[i].pstrOleObjFileName = NULL;
     6918        }
    69086919    }
    69096920    return hRes;
     
    69216932 *      Still some unknowns for the IStorage: "\002OlePres000", "\001CompObj",
    69226933 *      and "\001OLE" streams.
    6923  *
     6934 *     
    69246935 */
    69256936HRESULT WINAPI OleConvertIStorageToOLESTREAM (
    6926     LPSTORAGE pstg,
     6937    LPSTORAGE pstg, 
    69276938    LPOLESTREAM pOleStream)
    69286939{
     
    69496960    {
    69506961        /*Was it originaly Ole10 */
    6951         hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);
     6962        hRes = IStorage_OpenStream(pstg, wstrStreamName, 0, STGM_READ | STGM_SHARE_EXCLUSIVE, 0, &pStream);   
    69526963        if(hRes == S_OK)
    69536964        {
     
    69846995
    69856996/***********************************************************************
    6986  *      GetConvertStg (OLE32.68)
     6997 *              GetConvertStg (OLE32.68)
    69876998 */
    69886999HRESULT WINAPI GetConvertStg(LPGUID guid) {
     
    69987009 */
    69997010HRESULT WINAPI StgIsStorageFile16(LPCOLESTR16 fn) {
    7000     HFILE       hf;
    7001     OFSTRUCT    ofs;
    7002     BYTE        magic[24];
    7003 
    7004     TRACE("(\'%s\')\n",fn);
    7005     hf = OpenFile(fn,&ofs,OF_SHARE_DENY_NONE);
    7006     if (hf==HFILE_ERROR)
    7007         return STG_E_FILENOTFOUND;
    7008     if (24!=_lread(hf,magic,24)) {
    7009         WARN(" too short\n");
    7010         _lclose(hf);
    7011         return S_FALSE;
    7012     }
    7013     if (!memcmp(magic,STORAGE_magic,8)) {
    7014         WARN(" -> YES\n");
    7015         _lclose(hf);
    7016         return S_OK;
    7017     }
    7018     if (!memcmp(magic,STORAGE_notmagic,8)) {
    7019         WARN(" -> NO\n");
    7020         _lclose(hf);
    7021         return S_FALSE;
    7022     }
    7023     if (!memcmp(magic,STORAGE_oldmagic,8)) {
    7024         WARN(" -> old format\n");
    7025         _lclose(hf);
    7026         return STG_E_OLDFORMAT;
    7027     }
    7028     WARN(" -> Invalid header.\n");
    7029     _lclose(hf);
    7030     return STG_E_INVALIDHEADER;
     7011        HFILE           hf;
     7012        OFSTRUCT        ofs;
     7013        BYTE            magic[24];
     7014
     7015        TRACE("(\'%s\')\n",fn);
     7016        hf = OpenFile(fn,&ofs,OF_SHARE_DENY_NONE);
     7017        if (hf==HFILE_ERROR)
     7018                return STG_E_FILENOTFOUND;
     7019        if (24!=_lread(hf,magic,24)) {
     7020                WARN(" too short\n");
     7021                _lclose(hf);
     7022                return S_FALSE;
     7023        }
     7024        if (!memcmp(magic,STORAGE_magic,8)) {
     7025                WARN(" -> YES\n");
     7026                _lclose(hf);
     7027                return S_OK;
     7028        }
     7029        if (!memcmp(magic,STORAGE_notmagic,8)) {
     7030                WARN(" -> NO\n");
     7031                _lclose(hf);
     7032                return S_FALSE;
     7033        }
     7034        if (!memcmp(magic,STORAGE_oldmagic,8)) {
     7035                WARN(" -> old format\n");
     7036                _lclose(hf);
     7037                return STG_E_OLDFORMAT;
     7038        }
     7039        WARN(" -> Invalid header.\n");
     7040        _lclose(hf);
     7041        return STG_E_INVALIDHEADER;
    70317042}
    70327043
     
    70347045 * StgIsStorageFile [OLE32.146]
    70357046 */
    7036 HRESULT WINAPI
    7037 StgIsStorageFile(LPCOLESTR fn)
    7038 {
    7039     LPOLESTR16  xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);
    7040     HRESULT ret = StgIsStorageFile16(xfn);
    7041 
    7042     HeapFree(GetProcessHeap(),0,xfn);
    7043     return ret;
     7047HRESULT WINAPI 
     7048StgIsStorageFile(LPCOLESTR fn) 
     7049{
     7050        LPOLESTR16      xfn = HEAP_strdupWtoA(GetProcessHeap(),0,fn);
     7051        HRESULT ret = StgIsStorageFile16(xfn);
     7052
     7053        HeapFree(GetProcessHeap(),0,xfn);
     7054        return ret;
    70447055}
    70457056#endif
Note: See TracChangeset for help on using the changeset viewer.