Vincent Povirk : ole32: Copy the storage filename at stat time, not read time.

Alexandre Julliard julliard at winehq.org
Tue Nov 24 12:40:22 CST 2009


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

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Mon Nov 23 15:39:35 2009 -0600

ole32: Copy the storage filename at stat time, not read time.

---

 dlls/ole32/stg_stream.c |    3 ++-
 dlls/ole32/storage32.c  |   31 +++++++++++++++++++++----------
 dlls/ole32/storage32.h  |    4 ++--
 3 files changed, 25 insertions(+), 13 deletions(-)

diff --git a/dlls/ole32/stg_stream.c b/dlls/ole32/stg_stream.c
index 8b731dd..332ee8a 100644
--- a/dlls/ole32/stg_stream.c
+++ b/dlls/ole32/stg_stream.c
@@ -860,7 +860,8 @@ static HRESULT WINAPI StgStreamImpl_Stat(
   {
     StorageImpl *root = This->parentStorage->ancestorStorage;
 
-    StorageUtl_CopyDirEntryToSTATSTG(pstatstg,
+    StorageUtl_CopyDirEntryToSTATSTG(root,
+                     pstatstg,
 				     &currentEntry,
 				     grfStatFlag);
 
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 708f263..d4c6527 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -698,6 +698,7 @@ static HRESULT WINAPI StorageBaseImpl_Stat(
   if (readSuccessful)
   {
     StorageUtl_CopyDirEntryToSTATSTG(
+      This->ancestorStorage,
       pstatstg,
       &currentEntry,
       grfStatFlag);
@@ -3241,14 +3242,10 @@ BOOL StorageImpl_ReadDirEntry(
 
   if (SUCCEEDED(readRes))
   {
-    /* replace the name of root entry (often "Root Entry") by the file name */
-    WCHAR *entryName = (index == This->base.storageDirEntry) ?
-			This->filename : (WCHAR *)currentEntry+OFFSET_PS_NAME;
-
     memset(buffer->name, 0, sizeof(buffer->name));
     memcpy(
       buffer->name,
-      entryName,
+      (WCHAR *)currentEntry+OFFSET_PS_NAME,
       DIRENTRY_NAME_BUFFER_LEN );
     TRACE("storage name: %s\n", debugstr_w(buffer->name));
 
@@ -3750,7 +3747,8 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Next(
     /*
      * Copy the information to the return buffer.
      */
-    StorageUtl_CopyDirEntryToSTATSTG(currentReturnStruct,
+    StorageUtl_CopyDirEntryToSTATSTG(This->parentStorage,
+      currentReturnStruct,
       &currentEntry,
       STATFLAG_DEFAULT);
 
@@ -4179,25 +4177,38 @@ void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value)
 }
 
 void StorageUtl_CopyDirEntryToSTATSTG(
+  StorageImpl*          storage,
   STATSTG*              destination,
   const DirEntry*       source,
   int                   statFlags)
 {
+  LPCWSTR entryName;
+
+  if (source->stgType == STGTY_ROOT)
+  {
+    /* replace the name of root entry (often "Root Entry") by the file name */
+    entryName = storage->filename;
+  }
+  else
+  {
+    entryName = source->name;
+  }
+
   /*
    * The copy of the string occurs only when the flag is not set
    */
   if( ((statFlags & STATFLAG_NONAME) != 0) || 
-       (source->name == NULL) || 
-       (source->name[0] == 0) )
+       (entryName == NULL) ||
+       (entryName[0] == 0) )
   {
     destination->pwcsName = 0;
   }
   else
   {
     destination->pwcsName =
-      CoTaskMemAlloc((lstrlenW(source->name)+1)*sizeof(WCHAR));
+      CoTaskMemAlloc((lstrlenW(entryName)+1)*sizeof(WCHAR));
 
-    strcpyW(destination->pwcsName, source->name);
+    strcpyW(destination->pwcsName, entryName);
   }
 
   switch (source->stgType)
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index 4a953c1..508bd70 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -428,8 +428,8 @@ 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(STATSTG* destination, const DirEntry* source,
- int statFlags);
+void StorageUtl_CopyDirEntryToSTATSTG(StorageImpl *storage,STATSTG* destination,
+ const DirEntry* source, int statFlags);
 
 /****************************************************************************
  * BlockChainStream definitions.




More information about the wine-cvs mailing list