Name of the structured storage file root node is path of the file, not

the name of the root node stored in the file.
When reading streams stored into structured storage files, EOF is not
supposed to cause an error if at least one byte can be returned.
This commit is contained in:
Jukka Heinonen 2002-01-01 00:13:32 +00:00 committed by Alexandre Julliard
parent 562089b5d6
commit 420f6c0030
3 changed files with 59 additions and 9 deletions

View File

@ -379,12 +379,11 @@ HRESULT WINAPI StgStreamImpl_Read(
*/
This->currentPosition.s.LowPart += *pcbRead;
/*
* The function returns S_OK if the buffer was filled completely
* it returns S_FALSE if the end of the stream is reached before the
* buffer is filled
/*
* The function returns S_OK if at least one byte could be read.
* FIXME: What should be returned if pcbRead argument is NULL?
*/
if(*pcbRead == cb)
if (*pcbRead > 0)
return S_OK;
return S_FALSE;

View File

@ -159,7 +159,7 @@ static ICOM_VTABLE(IStorage) Storage32Impl_Vtbl =
StorageImpl_SetElementTimes,
StorageBaseImpl_SetClass,
StorageImpl_SetStateBits,
StorageBaseImpl_Stat
StorageImpl_Stat
};
/*
@ -1679,6 +1679,32 @@ HRESULT WINAPI StorageImpl_DestroyElement(
}
/************************************************************************
* StorageImpl_Stat (IStorage)
*
* This method will retrieve information about this storage object.
*
* See Windows documentation for more details on IStorage methods.
*/
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 ( !FAILED(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 Method
@ -2094,6 +2120,7 @@ HRESULT WINAPI StorageImpl_SetStateBits(
HRESULT StorageImpl_Construct(
StorageImpl* This,
HANDLE hFile,
LPCOLESTR pwcsName,
ILockBytes* pLkbyt,
DWORD openFlags,
BOOL fileBased,
@ -2103,7 +2130,7 @@ HRESULT StorageImpl_Construct(
StgProperty currentProperty;
BOOL readSuccessful;
ULONG currentPropertyIndex;
if ( FAILED( validateSTGM(openFlags) ))
return STG_E_INVALIDFLAG;
@ -2126,6 +2153,17 @@ HRESULT StorageImpl_Construct(
*/
This->hFile = hFile;
/*
* Store copy of file path.
*/
if(pwcsName) {
This->pwcsName = HeapAlloc(GetProcessHeap(), 0,
(lstrlenW(pwcsName)+1)*sizeof(WCHAR));
if (!This->pwcsName)
return STG_E_INSUFFICIENTMEMORY;
strcpyW(This->pwcsName, pwcsName);
}
/*
* Initialize the big block cache.
*/
@ -2289,6 +2327,9 @@ void StorageImpl_Destroy(
{
TRACE("(%p)\n", This);
if(This->pwcsName)
HeapFree(GetProcessHeap(), 0, This->pwcsName);
BlockChainStream_Destroy(This->smallBlockRootChain);
BlockChainStream_Destroy(This->rootBlockChain);
BlockChainStream_Destroy(This->smallBlockDepotChain);
@ -5360,6 +5401,7 @@ HRESULT WINAPI StgCreateDocfile(
hr = StorageImpl_Construct(
newStorage,
hFile,
pwcsName,
NULL,
grfMode,
TRUE,
@ -5477,6 +5519,7 @@ HRESULT WINAPI StgOpenStorage(
hr = StorageImpl_Construct(
newStorage,
hFile,
pwcsName,
NULL,
grfMode,
TRUE,
@ -5533,6 +5576,7 @@ HRESULT WINAPI StgCreateDocfileOnILockBytes(
hr = StorageImpl_Construct(
newStorage,
0,
0,
plkbyt,
grfMode,
FALSE,
@ -5597,6 +5641,7 @@ HRESULT WINAPI StgOpenStorageOnILockBytes(
hr = StorageImpl_Construct(
newStorage,
0,
0,
plkbyt,
grfMode,
FALSE,

View File

@ -298,7 +298,8 @@ struct StorageImpl
* class
*/
HANDLE hFile; /* Physical support for the Docfile */
LPOLESTR pwcsName; /* Full path of the document file */
/*
* File header
*/
@ -378,13 +379,18 @@ HRESULT WINAPI StorageImpl_SetStateBits(
IStorage* iface,
DWORD grfStateBits, /* [in] */
DWORD grfMask); /* [in] */
HRESULT WINAPI StorageImpl_Stat(IStorage* iface,
STATSTG* pstatstg, /* [out] */
DWORD grfStatFlag); /* [in] */
void StorageImpl_Destroy(
StorageImpl* This);
HRESULT StorageImpl_Construct(
StorageImpl* This,
HANDLE hFile,
LPCOLESTR pwcsName,
ILockBytes* pLkbyt,
DWORD openFlags,
BOOL fileBased,