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.
This commit is contained in:
Vincent Povirk 2009-12-02 12:35:53 -06:00 committed by Alexandre Julliard
parent 5456724fd7
commit f434ab1f2a
3 changed files with 14 additions and 37 deletions

View File

@ -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);

View File

@ -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.

View File

@ -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);
/****************************************************************************