Commit 6c3961f0 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

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

parent 9943facb
...@@ -860,7 +860,8 @@ static HRESULT WINAPI StgStreamImpl_Stat( ...@@ -860,7 +860,8 @@ static HRESULT WINAPI StgStreamImpl_Stat(
{ {
StorageImpl *root = This->parentStorage->ancestorStorage; StorageImpl *root = This->parentStorage->ancestorStorage;
StorageUtl_CopyDirEntryToSTATSTG(pstatstg, StorageUtl_CopyDirEntryToSTATSTG(root,
pstatstg,
&currentEntry, &currentEntry,
grfStatFlag); grfStatFlag);
......
...@@ -698,6 +698,7 @@ static HRESULT WINAPI StorageBaseImpl_Stat( ...@@ -698,6 +698,7 @@ static HRESULT WINAPI StorageBaseImpl_Stat(
if (readSuccessful) if (readSuccessful)
{ {
StorageUtl_CopyDirEntryToSTATSTG( StorageUtl_CopyDirEntryToSTATSTG(
This->ancestorStorage,
pstatstg, pstatstg,
&currentEntry, &currentEntry,
grfStatFlag); grfStatFlag);
...@@ -3241,14 +3242,10 @@ BOOL StorageImpl_ReadDirEntry( ...@@ -3241,14 +3242,10 @@ BOOL StorageImpl_ReadDirEntry(
if (SUCCEEDED(readRes)) 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)); memset(buffer->name, 0, sizeof(buffer->name));
memcpy( memcpy(
buffer->name, buffer->name,
entryName, (WCHAR *)currentEntry+OFFSET_PS_NAME,
DIRENTRY_NAME_BUFFER_LEN ); DIRENTRY_NAME_BUFFER_LEN );
TRACE("storage name: %s\n", debugstr_w(buffer->name)); TRACE("storage name: %s\n", debugstr_w(buffer->name));
...@@ -3750,7 +3747,8 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Next( ...@@ -3750,7 +3747,8 @@ static HRESULT WINAPI IEnumSTATSTGImpl_Next(
/* /*
* Copy the information to the return buffer. * Copy the information to the return buffer.
*/ */
StorageUtl_CopyDirEntryToSTATSTG(currentReturnStruct, StorageUtl_CopyDirEntryToSTATSTG(This->parentStorage,
currentReturnStruct,
&currentEntry, &currentEntry,
STATFLAG_DEFAULT); STATFLAG_DEFAULT);
...@@ -4179,25 +4177,38 @@ void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value) ...@@ -4179,25 +4177,38 @@ void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value)
} }
void StorageUtl_CopyDirEntryToSTATSTG( void StorageUtl_CopyDirEntryToSTATSTG(
StorageImpl* storage,
STATSTG* destination, STATSTG* destination,
const DirEntry* source, const DirEntry* source,
int statFlags) 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 * The copy of the string occurs only when the flag is not set
*/ */
if( ((statFlags & STATFLAG_NONAME) != 0) || if( ((statFlags & STATFLAG_NONAME) != 0) ||
(source->name == NULL) || (entryName == NULL) ||
(source->name[0] == 0) ) (entryName[0] == 0) )
{ {
destination->pwcsName = 0; destination->pwcsName = 0;
} }
else else
{ {
destination->pwcsName = 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) switch (source->stgType)
......
...@@ -428,8 +428,8 @@ void StorageUtl_WriteULargeInteger(BYTE* buffer, ULONG offset, ...@@ -428,8 +428,8 @@ void StorageUtl_WriteULargeInteger(BYTE* buffer, ULONG offset,
const ULARGE_INTEGER *value); const ULARGE_INTEGER *value);
void StorageUtl_ReadGUID(const BYTE* buffer, ULONG offset, GUID* value); void StorageUtl_ReadGUID(const BYTE* buffer, ULONG offset, GUID* value);
void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value); void StorageUtl_WriteGUID(BYTE* buffer, ULONG offset, const GUID* value);
void StorageUtl_CopyDirEntryToSTATSTG(STATSTG* destination, const DirEntry* source, void StorageUtl_CopyDirEntryToSTATSTG(StorageImpl *storage,STATSTG* destination,
int statFlags); const DirEntry* source, int statFlags);
/**************************************************************************** /****************************************************************************
* BlockChainStream definitions. * BlockChainStream definitions.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment