Commit 420f6c00 authored by Jukka Heinonen's avatar Jukka Heinonen Committed by Alexandre Julliard

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.
parent 562089b5
...@@ -379,12 +379,11 @@ HRESULT WINAPI StgStreamImpl_Read( ...@@ -379,12 +379,11 @@ HRESULT WINAPI StgStreamImpl_Read(
*/ */
This->currentPosition.s.LowPart += *pcbRead; This->currentPosition.s.LowPart += *pcbRead;
/* /*
* The function returns S_OK if the buffer was filled completely * The function returns S_OK if at least one byte could be read.
* it returns S_FALSE if the end of the stream is reached before the * FIXME: What should be returned if pcbRead argument is NULL?
* buffer is filled
*/ */
if(*pcbRead == cb) if (*pcbRead > 0)
return S_OK; return S_OK;
return S_FALSE; return S_FALSE;
......
...@@ -159,7 +159,7 @@ static ICOM_VTABLE(IStorage) Storage32Impl_Vtbl = ...@@ -159,7 +159,7 @@ static ICOM_VTABLE(IStorage) Storage32Impl_Vtbl =
StorageImpl_SetElementTimes, StorageImpl_SetElementTimes,
StorageBaseImpl_SetClass, StorageBaseImpl_SetClass,
StorageImpl_SetStateBits, StorageImpl_SetStateBits,
StorageBaseImpl_Stat StorageImpl_Stat
}; };
/* /*
...@@ -1679,6 +1679,32 @@ HRESULT WINAPI StorageImpl_DestroyElement( ...@@ -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 * Internal Method
...@@ -2094,6 +2120,7 @@ HRESULT WINAPI StorageImpl_SetStateBits( ...@@ -2094,6 +2120,7 @@ HRESULT WINAPI StorageImpl_SetStateBits(
HRESULT StorageImpl_Construct( HRESULT StorageImpl_Construct(
StorageImpl* This, StorageImpl* This,
HANDLE hFile, HANDLE hFile,
LPCOLESTR pwcsName,
ILockBytes* pLkbyt, ILockBytes* pLkbyt,
DWORD openFlags, DWORD openFlags,
BOOL fileBased, BOOL fileBased,
...@@ -2103,7 +2130,7 @@ HRESULT StorageImpl_Construct( ...@@ -2103,7 +2130,7 @@ HRESULT StorageImpl_Construct(
StgProperty currentProperty; StgProperty currentProperty;
BOOL readSuccessful; BOOL readSuccessful;
ULONG currentPropertyIndex; ULONG currentPropertyIndex;
if ( FAILED( validateSTGM(openFlags) )) if ( FAILED( validateSTGM(openFlags) ))
return STG_E_INVALIDFLAG; return STG_E_INVALIDFLAG;
...@@ -2127,6 +2154,17 @@ HRESULT StorageImpl_Construct( ...@@ -2127,6 +2154,17 @@ HRESULT StorageImpl_Construct(
This->hFile = hFile; 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. * Initialize the big block cache.
*/ */
This->bigBlockSize = DEF_BIG_BLOCK_SIZE; This->bigBlockSize = DEF_BIG_BLOCK_SIZE;
...@@ -2289,6 +2327,9 @@ void StorageImpl_Destroy( ...@@ -2289,6 +2327,9 @@ void StorageImpl_Destroy(
{ {
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
if(This->pwcsName)
HeapFree(GetProcessHeap(), 0, This->pwcsName);
BlockChainStream_Destroy(This->smallBlockRootChain); BlockChainStream_Destroy(This->smallBlockRootChain);
BlockChainStream_Destroy(This->rootBlockChain); BlockChainStream_Destroy(This->rootBlockChain);
BlockChainStream_Destroy(This->smallBlockDepotChain); BlockChainStream_Destroy(This->smallBlockDepotChain);
...@@ -5360,6 +5401,7 @@ HRESULT WINAPI StgCreateDocfile( ...@@ -5360,6 +5401,7 @@ HRESULT WINAPI StgCreateDocfile(
hr = StorageImpl_Construct( hr = StorageImpl_Construct(
newStorage, newStorage,
hFile, hFile,
pwcsName,
NULL, NULL,
grfMode, grfMode,
TRUE, TRUE,
...@@ -5477,6 +5519,7 @@ HRESULT WINAPI StgOpenStorage( ...@@ -5477,6 +5519,7 @@ HRESULT WINAPI StgOpenStorage(
hr = StorageImpl_Construct( hr = StorageImpl_Construct(
newStorage, newStorage,
hFile, hFile,
pwcsName,
NULL, NULL,
grfMode, grfMode,
TRUE, TRUE,
...@@ -5533,6 +5576,7 @@ HRESULT WINAPI StgCreateDocfileOnILockBytes( ...@@ -5533,6 +5576,7 @@ HRESULT WINAPI StgCreateDocfileOnILockBytes(
hr = StorageImpl_Construct( hr = StorageImpl_Construct(
newStorage, newStorage,
0, 0,
0,
plkbyt, plkbyt,
grfMode, grfMode,
FALSE, FALSE,
...@@ -5597,6 +5641,7 @@ HRESULT WINAPI StgOpenStorageOnILockBytes( ...@@ -5597,6 +5641,7 @@ HRESULT WINAPI StgOpenStorageOnILockBytes(
hr = StorageImpl_Construct( hr = StorageImpl_Construct(
newStorage, newStorage,
0, 0,
0,
plkbyt, plkbyt,
grfMode, grfMode,
FALSE, FALSE,
......
...@@ -298,7 +298,8 @@ struct StorageImpl ...@@ -298,7 +298,8 @@ struct StorageImpl
* class * class
*/ */
HANDLE hFile; /* Physical support for the Docfile */ HANDLE hFile; /* Physical support for the Docfile */
LPOLESTR pwcsName; /* Full path of the document file */
/* /*
* File header * File header
*/ */
...@@ -378,13 +379,18 @@ HRESULT WINAPI StorageImpl_SetStateBits( ...@@ -378,13 +379,18 @@ HRESULT WINAPI StorageImpl_SetStateBits(
IStorage* iface, IStorage* iface,
DWORD grfStateBits, /* [in] */ DWORD grfStateBits, /* [in] */
DWORD grfMask); /* [in] */ DWORD grfMask); /* [in] */
HRESULT WINAPI StorageImpl_Stat(IStorage* iface,
STATSTG* pstatstg, /* [out] */
DWORD grfStatFlag); /* [in] */
void StorageImpl_Destroy( void StorageImpl_Destroy(
StorageImpl* This); StorageImpl* This);
HRESULT StorageImpl_Construct( HRESULT StorageImpl_Construct(
StorageImpl* This, StorageImpl* This,
HANDLE hFile, HANDLE hFile,
LPCOLESTR pwcsName,
ILockBytes* pLkbyt, ILockBytes* pLkbyt,
DWORD openFlags, DWORD openFlags,
BOOL fileBased, BOOL fileBased,
......
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