Vincent Povirk : ole32: Unify the logic for overriding the root storage filename in Stat.

Alexandre Julliard julliard at winehq.org
Fri Dec 4 09:11:29 CST 2009


Module: wine
Branch: master
Commit: f434ab1f2aa3b0c330c44f135c8ffce039d7016f
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=f434ab1f2aa3b0c330c44f135c8ffce039d7016f

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Wed Dec  2 12:35:53 2009 -0600

ole32: Unify the logic for overriding the root storage filename in Stat.

This is needed so that the new transacted type will be able to easily support
this logic.

---

 dlls/ole32/stg_stream.c |    4 +---
 dlls/ole32/storage32.c  |   39 +++++++++------------------------------
 dlls/ole32/storage32.h  |    8 ++++----
 3 files changed, 14 insertions(+), 37 deletions(-)

diff --git a/dlls/ole32/stg_stream.c b/dlls/ole32/stg_stream.c
index bf88c64..5355594 100644
--- a/dlls/ole32/stg_stream.c
+++ b/dlls/ole32/stg_stream.c
@@ -858,9 +858,7 @@ static HRESULT WINAPI StgStreamImpl_Stat(
 
   if (readSuccessful)
   {
-    StorageImpl *root = This->parentStorage->ancestorStorage;
-
-    StorageUtl_CopyDirEntryToSTATSTG(root,
+    StorageUtl_CopyDirEntryToSTATSTG(This->parentStorage,
                      pstatstg,
 				     &currentEntry,
 				     grfStatFlag);
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 971f44a..8f9683f 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -704,7 +704,7 @@ static HRESULT WINAPI StorageBaseImpl_Stat(
   if (readSuccessful)
   {
     StorageUtl_CopyDirEntryToSTATSTG(
-      This->ancestorStorage,
+      This,
       pstatstg,
       &currentEntry,
       grfStatFlag);
@@ -1841,30 +1841,6 @@ static HRESULT WINAPI StorageBaseImpl_DestroyElement(
 }
 
 
-/************************************************************************
- * StorageImpl_Stat (IStorage)
- *
- * This method will retrieve information about this storage object.
- *
- * See Windows documentation for more details on IStorage methods.
- */
-static HRESULT WINAPI StorageImpl_Stat( IStorage* iface,
-                                 STATSTG*  pstatstg,     /* [out] */
-                                 DWORD     grfStatFlag)  /* [in] */
-{
-  StorageImpl* const This = (StorageImpl*)iface;
-  HRESULT result = StorageBaseImpl_Stat( iface, pstatstg, grfStatFlag );
-
-  if ( SUCCEEDED(result) && ((grfStatFlag & STATFLAG_NONAME) == 0) && This->pwcsName )
-  {
-      CoTaskMemFree(pstatstg->pwcsName);
-      pstatstg->pwcsName = CoTaskMemAlloc((lstrlenW(This->pwcsName)+1)*sizeof(WCHAR));
-      strcpyW(pstatstg->pwcsName, This->pwcsName);
-  }
-
-  return result;
-}
-
 /******************************************************************************
  * Internal stream list handlers
  */
@@ -2240,7 +2216,7 @@ static const IStorageVtbl Storage32Impl_Vtbl =
     StorageBaseImpl_SetElementTimes,
     StorageBaseImpl_SetClass,
     StorageBaseImpl_SetStateBits,
-    StorageImpl_Stat
+    StorageBaseImpl_Stat
 };
 
 static HRESULT StorageImpl_Construct(
@@ -2295,6 +2271,9 @@ static HRESULT StorageImpl_Construct(
          goto end;
       }
       strcpyW(This->pwcsName, pwcsName);
+
+      memcpy(This->base.filename, pwcsName, DIRENTRY_NAME_BUFFER_LEN-1);
+      This->base.filename[DIRENTRY_NAME_BUFFER_LEN-1] = 0;
   }
 
   /*
@@ -3786,7 +3765,7 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Next(
     /*
      * Copy the information to the return buffer.
      */
-    StorageUtl_CopyDirEntryToSTATSTG(This->parentStorage,
+    StorageUtl_CopyDirEntryToSTATSTG(&This->parentStorage->base,
       currentReturnStruct,
       &currentEntry,
       STATFLAG_DEFAULT);
@@ -4218,7 +4197,7 @@ void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value)
 }
 
 void StorageUtl_CopyDirEntryToSTATSTG(
-  StorageImpl*          storage,
+  StorageBaseImpl*      storage,
   STATSTG*              destination,
   const DirEntry*       source,
   int                   statFlags)
@@ -5998,8 +5977,8 @@ HRESULT WINAPI StgOpenStorage(
 
   /* prepare the file name string given in lieu of the root property name */
   GetFullPathNameW(pwcsName, MAX_PATH, fullname, NULL);
-  memcpy(newStorage->filename, fullname, DIRENTRY_NAME_BUFFER_LEN);
-  newStorage->filename[DIRENTRY_NAME_BUFFER_LEN-1] = '\0';
+  memcpy(newStorage->base.filename, fullname, DIRENTRY_NAME_BUFFER_LEN);
+  newStorage->base.filename[DIRENTRY_NAME_BUFFER_LEN-1] = '\0';
 
   /*
    * Get an "out" pointer for the caller.
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index 59a8fb9..20de0eb 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -236,6 +236,9 @@ struct StorageBaseImpl
    */
   DWORD stateBits;
 
+  /* If set, this overrides the root storage name returned by IStorage_Stat */
+  WCHAR            filename[DIRENTRY_NAME_BUFFER_LEN];
+
   BOOL             create;     /* Was the storage created or opened.
                                   The behaviour of STGM_SIMPLE depends on this */
 };
@@ -264,9 +267,6 @@ struct StorageImpl
   HANDLE           hFile;      /* Physical support for the Docfile */
   LPOLESTR         pwcsName;   /* Full path of the document file */
 
-  /* FIXME: should this be in Storage32BaseImpl ? */
-  WCHAR            filename[DIRENTRY_NAME_BUFFER_LEN];
-
   /*
    * File header
    */
@@ -429,7 +429,7 @@ void StorageUtl_WriteULargeInteger(BYTE* buffer, ULONG offset,
  const ULARGE_INTEGER *value);
 void StorageUtl_ReadGUID(const BYTE* buffer, ULONG offset, GUID* value);
 void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value);
-void StorageUtl_CopyDirEntryToSTATSTG(StorageImpl *storage,STATSTG* destination,
+void StorageUtl_CopyDirEntryToSTATSTG(StorageBaseImpl *storage,STATSTG* destination,
  const DirEntry* source, int statFlags);
 
 /****************************************************************************




More information about the wine-cvs mailing list