1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Compound Storage (32 bit version)
|
|
|
|
* Stream implementation
|
|
|
|
*
|
|
|
|
* This file contains the implementation of the stream interface
|
|
|
|
* for streams contained in a compound storage.
|
|
|
|
*
|
|
|
|
* Copyright 1999 Francis Beaudet
|
|
|
|
* Copyright 1999 Thuy Nguyen
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
1999-01-30 14:24:23 +01:00
|
|
|
*/
|
2003-01-07 21:36:20 +01:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
1999-01-30 14:24:23 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2004-10-07 05:06:48 +02:00
|
|
|
#define COBJMACROS
|
2003-01-07 21:36:20 +01:00
|
|
|
#define NONAMELESSUNION
|
|
|
|
#define NONAMELESSSTRUCT
|
2004-10-07 05:06:48 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-02-28 20:14:33 +01:00
|
|
|
#include "winbase.h"
|
1999-01-30 14:24:23 +01:00
|
|
|
#include "winerror.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winreg.h"
|
2002-09-13 00:07:02 +02:00
|
|
|
#include "winternl.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
#include "storage32.h"
|
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(storage);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
/***
|
|
|
|
* This is the destructor of the StgStreamImpl class.
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* This method will clean-up all the resources used-up by the given StgStreamImpl
|
1999-01-30 14:24:23 +01:00
|
|
|
* class. The pointer passed-in to this function will be freed and will not
|
|
|
|
* be valid anymore.
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static void StgStreamImpl_Destroy(StgStreamImpl* This)
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p)\n", This);
|
1999-05-02 13:41:10 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Release the reference we are holding on the parent storage.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
IStorage_Release((IStorage*)This->parentStorage);
|
1999-01-30 14:24:23 +01:00
|
|
|
This->parentStorage = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure we clean-up the block chain stream objects that we were using.
|
|
|
|
*/
|
|
|
|
if (This->bigBlockChain != 0)
|
|
|
|
{
|
|
|
|
BlockChainStream_Destroy(This->bigBlockChain);
|
|
|
|
This->bigBlockChain = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->smallBlockChain != 0)
|
|
|
|
{
|
|
|
|
SmallBlockChainStream_Destroy(This->smallBlockChain);
|
|
|
|
This->smallBlockChain = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finally, free the memory used-up by the class.
|
|
|
|
*/
|
2002-06-01 01:06:46 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This);
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This implements the IUnknown method QueryInterface for this
|
|
|
|
* class
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_QueryInterface(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
REFIID riid, /* [in] */
|
|
|
|
void** ppvObject) /* [iid_is][out] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
StgStreamImpl* const This=(StgStreamImpl*)iface;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Perform a sanity check on the parameters.
|
|
|
|
*/
|
|
|
|
if (ppvObject==0)
|
|
|
|
return E_INVALIDARG;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Initialize the return parameter.
|
|
|
|
*/
|
|
|
|
*ppvObject = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Compare the riid with the interface IDs implemented by this object.
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
if (IsEqualGUID(&IID_IUnknown, riid)||
|
|
|
|
IsEqualGUID(&IID_IStream, riid))
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
*ppvObject = (IStream*)This;
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Check that we obtained an interface.
|
|
|
|
*/
|
|
|
|
if ((*ppvObject)==0)
|
|
|
|
return E_NOINTERFACE;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Query Interface always increases the reference count by one when it is
|
|
|
|
* successful
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
IStream_AddRef(iface);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
|
|
|
return S_OK;
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This implements the IUnknown method AddRef for this
|
|
|
|
* class
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static ULONG WINAPI StgStreamImpl_AddRef(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface)
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
StgStreamImpl* const This=(StgStreamImpl*)iface;
|
2004-09-24 03:16:53 +02:00
|
|
|
return InterlockedIncrement(&This->ref);
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This implements the IUnknown method Release for this
|
|
|
|
* class
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static ULONG WINAPI StgStreamImpl_Release(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface)
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
StgStreamImpl* const This=(StgStreamImpl*)iface;
|
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
ULONG ref;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
ref = InterlockedDecrement(&This->ref);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* If the reference count goes down to 0, perform suicide.
|
|
|
|
*/
|
2004-09-24 03:16:53 +02:00
|
|
|
if (ref==0)
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
|
|
|
StgStreamImpl_Destroy(This);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-09-24 03:16:53 +02:00
|
|
|
return ref;
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This method will open the block chain pointed by the property
|
|
|
|
* that describes the stream.
|
|
|
|
* If the stream's size is null, no chain is opened.
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static void StgStreamImpl_OpenBlockChain(
|
1999-01-30 14:24:23 +01:00
|
|
|
StgStreamImpl* This)
|
|
|
|
{
|
|
|
|
StgProperty curProperty;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL readSucessful;
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
/*
|
2002-01-31 22:01:35 +01:00
|
|
|
* Make sure no old object is left over.
|
1999-01-30 14:24:23 +01:00
|
|
|
*/
|
|
|
|
if (This->smallBlockChain != 0)
|
|
|
|
{
|
|
|
|
SmallBlockChainStream_Destroy(This->smallBlockChain);
|
|
|
|
This->smallBlockChain = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (This->bigBlockChain != 0)
|
|
|
|
{
|
|
|
|
BlockChainStream_Destroy(This->bigBlockChain);
|
|
|
|
This->bigBlockChain = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the information from the property.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
|
1999-01-30 14:24:23 +01:00
|
|
|
This->ownerProperty,
|
|
|
|
&curProperty);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
if (readSucessful)
|
|
|
|
{
|
|
|
|
This->streamSize = curProperty.size;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* This code supports only streams that are <32 bits in size.
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
assert(This->streamSize.u.HighPart == 0);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
if(curProperty.startingBlock == BLOCK_END_OF_CHAIN)
|
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
assert( (This->streamSize.u.HighPart == 0) && (This->streamSize.u.LowPart == 0) );
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
if ( (This->streamSize.u.HighPart == 0) &&
|
|
|
|
(This->streamSize.u.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
|
|
|
This->smallBlockChain = SmallBlockChainStream_Construct(
|
2002-06-01 01:06:46 +02:00
|
|
|
This->parentStorage->ancestorStorage,
|
1999-01-30 14:24:23 +01:00
|
|
|
This->ownerProperty);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
This->bigBlockChain = BlockChainStream_Construct(
|
|
|
|
This->parentStorage->ancestorStorage,
|
|
|
|
NULL,
|
|
|
|
This->ownerProperty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This method is part of the ISequentialStream interface.
|
|
|
|
*
|
2002-01-31 22:01:35 +01:00
|
|
|
* It reads a block of information from the stream at the current
|
1999-01-30 14:24:23 +01:00
|
|
|
* position. It then moves the current position at the end of the
|
|
|
|
* read block
|
|
|
|
*
|
|
|
|
* See the documentation of ISequentialStream for more info.
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_Read(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
1999-01-30 14:24:23 +01:00
|
|
|
void* pv, /* [length_is][size_is][out] */
|
2002-06-01 01:06:46 +02:00
|
|
|
ULONG cb, /* [in] */
|
|
|
|
ULONG* pcbRead) /* [out] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
StgStreamImpl* const This=(StgStreamImpl*)iface;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
ULONG bytesReadBuffer;
|
|
|
|
ULONG bytesToReadFromBuffer;
|
2006-01-03 12:07:34 +01:00
|
|
|
HRESULT res;
|
1999-05-02 13:41:10 +02:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p, %ld, %p)\n",
|
1999-05-02 13:41:10 +02:00
|
|
|
iface, pv, cb, pcbRead);
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/*
|
2002-01-31 22:01:35 +01:00
|
|
|
* If the caller is not interested in the number of bytes read,
|
1999-01-30 14:24:23 +01:00
|
|
|
* we use another buffer to avoid "if" statements in the code.
|
|
|
|
*/
|
|
|
|
if (pcbRead==0)
|
|
|
|
pcbRead = &bytesReadBuffer;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Using the known size of the stream, calculate the number of bytes
|
|
|
|
* to read from the block chain
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
bytesToReadFromBuffer = min( This->streamSize.u.LowPart - This->currentPosition.u.LowPart, cb);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Depending on the type of chain that was opened when the stream was constructed,
|
2002-01-31 22:01:35 +01:00
|
|
|
* we delegate the work to the method that reads the block chains.
|
1999-01-30 14:24:23 +01:00
|
|
|
*/
|
|
|
|
if (This->smallBlockChain!=0)
|
|
|
|
{
|
2005-12-22 17:15:05 +01:00
|
|
|
res = SmallBlockChainStream_ReadAt(This->smallBlockChain,
|
1999-01-30 14:24:23 +01:00
|
|
|
This->currentPosition,
|
|
|
|
bytesToReadFromBuffer,
|
|
|
|
pv,
|
|
|
|
pcbRead);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
|
|
|
else if (This->bigBlockChain!=0)
|
|
|
|
{
|
2006-01-03 12:07:34 +01:00
|
|
|
BOOL success = BlockChainStream_ReadAt(This->bigBlockChain,
|
|
|
|
This->currentPosition,
|
|
|
|
bytesToReadFromBuffer,
|
|
|
|
pv,
|
|
|
|
pcbRead);
|
|
|
|
if (success)
|
|
|
|
res = S_OK;
|
|
|
|
else
|
|
|
|
res = STG_E_READFAULT;
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
|
|
|
else
|
1999-07-10 12:13:50 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Small and big block chains are both NULL. This case will happen
|
|
|
|
* when a stream starts with BLOCK_END_OF_CHAIN and has size zero.
|
|
|
|
*/
|
|
|
|
|
|
|
|
*pcbRead = 0;
|
2002-01-31 22:01:35 +01:00
|
|
|
res = S_OK;
|
|
|
|
goto end;
|
1999-07-10 12:13:50 +02:00
|
|
|
}
|
1999-01-30 14:24:23 +01:00
|
|
|
|
2005-12-22 17:15:05 +01:00
|
|
|
if (SUCCEEDED(res))
|
2002-01-31 22:01:35 +01:00
|
|
|
{
|
2005-12-22 17:15:05 +01:00
|
|
|
/*
|
|
|
|
* We should always be able to read the proper amount of data from the
|
|
|
|
* chain.
|
|
|
|
*/
|
|
|
|
assert(bytesToReadFromBuffer == *pcbRead);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Advance the pointer for the number of positions read.
|
|
|
|
*/
|
|
|
|
This->currentPosition.u.LowPart += *pcbRead;
|
2002-01-31 22:01:35 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-31 22:01:35 +01:00
|
|
|
end:
|
|
|
|
TRACE("<-- %08lx\n", res);
|
|
|
|
return res;
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/***
|
|
|
|
* This method is part of the ISequentialStream interface.
|
|
|
|
*
|
|
|
|
* It writes a block of information to the stream at the current
|
|
|
|
* position. It then moves the current position at the end of the
|
|
|
|
* written block. If the stream is too small to fit the block,
|
|
|
|
* the stream is grown to fit.
|
|
|
|
*
|
|
|
|
* See the documentation of ISequentialStream for more info.
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_Write(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
const void* pv, /* [size_is][in] */
|
|
|
|
ULONG cb, /* [in] */
|
|
|
|
ULONG* pcbWritten) /* [out] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
StgStreamImpl* const This=(StgStreamImpl*)iface;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
ULARGE_INTEGER newSize;
|
|
|
|
ULONG bytesWritten = 0;
|
1999-05-02 13:41:10 +02:00
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %p, %ld, %p)\n",
|
1999-05-02 13:41:10 +02:00
|
|
|
iface, pv, cb, pcbWritten);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-05-03 19:39:21 +02:00
|
|
|
/*
|
|
|
|
* Do we have permission to write to this stream?
|
|
|
|
*/
|
2005-03-07 13:24:42 +01:00
|
|
|
switch(STGM_ACCESS_MODE(This->grfMode))
|
|
|
|
{
|
|
|
|
case STGM_WRITE:
|
|
|
|
case STGM_READWRITE:
|
|
|
|
break;
|
|
|
|
default:
|
2000-05-03 19:39:21 +02:00
|
|
|
return STG_E_ACCESSDENIED;
|
|
|
|
}
|
2000-01-26 03:04:44 +01:00
|
|
|
|
2005-01-11 11:44:28 +01:00
|
|
|
if (!pv)
|
|
|
|
return STG_E_INVALIDPOINTER;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* If the caller is not interested in the number of bytes written,
|
|
|
|
* we use another buffer to avoid "if" statements in the code.
|
|
|
|
*/
|
|
|
|
if (pcbWritten == 0)
|
|
|
|
pcbWritten = &bytesWritten;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 13:41:10 +02:00
|
|
|
/*
|
|
|
|
* Initialize the out parameter
|
|
|
|
*/
|
|
|
|
*pcbWritten = 0;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
if (cb == 0)
|
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
newSize.u.HighPart = 0;
|
|
|
|
newSize.u.LowPart = This->currentPosition.u.LowPart + cb;
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Verify if we need to grow the stream
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
if (newSize.u.LowPart > This->streamSize.u.LowPart)
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
|
|
|
/* grow stream */
|
1999-05-02 13:41:10 +02:00
|
|
|
IStream_SetSize(iface, newSize);
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Depending on the type of chain that was opened when the stream was constructed,
|
|
|
|
* we delegate the work to the method that readwrites to the block chains.
|
|
|
|
*/
|
|
|
|
if (This->smallBlockChain!=0)
|
|
|
|
{
|
|
|
|
SmallBlockChainStream_WriteAt(This->smallBlockChain,
|
|
|
|
This->currentPosition,
|
|
|
|
cb,
|
|
|
|
pv,
|
|
|
|
pcbWritten);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
|
|
|
else if (This->bigBlockChain!=0)
|
|
|
|
{
|
|
|
|
BlockChainStream_WriteAt(This->bigBlockChain,
|
|
|
|
This->currentPosition,
|
|
|
|
cb,
|
|
|
|
pv,
|
|
|
|
pcbWritten);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
assert(FALSE);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Advance the position pointer for the number of positions written.
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
This->currentPosition.u.LowPart += *pcbWritten;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This method is part of the IStream interface.
|
|
|
|
*
|
|
|
|
* It will move the current stream pointer according to the parameters
|
|
|
|
* given.
|
|
|
|
*
|
|
|
|
* See the documentation of IStream for more info.
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_Seek(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
LARGE_INTEGER dlibMove, /* [in] */
|
|
|
|
DWORD dwOrigin, /* [in] */
|
1999-01-30 14:24:23 +01:00
|
|
|
ULARGE_INTEGER* plibNewPosition) /* [out] */
|
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
StgStreamImpl* const This=(StgStreamImpl*)iface;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
ULARGE_INTEGER newPosition;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%p, %ld, %ld, %p)\n",
|
2004-01-23 02:51:33 +01:00
|
|
|
iface, dlibMove.u.LowPart, dwOrigin, plibNewPosition);
|
1999-05-02 13:41:10 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
/*
|
1999-01-30 14:24:23 +01:00
|
|
|
* The caller is allowed to pass in NULL as the new position return value.
|
|
|
|
* If it happens, we assign it to a dynamic variable to avoid special cases
|
|
|
|
* in the code below.
|
|
|
|
*/
|
|
|
|
if (plibNewPosition == 0)
|
|
|
|
{
|
|
|
|
plibNewPosition = &newPosition;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The file pointer is moved depending on the given "function"
|
|
|
|
* parameter.
|
|
|
|
*/
|
|
|
|
switch (dwOrigin)
|
|
|
|
{
|
|
|
|
case STREAM_SEEK_SET:
|
2004-01-23 02:51:33 +01:00
|
|
|
plibNewPosition->u.HighPart = 0;
|
|
|
|
plibNewPosition->u.LowPart = 0;
|
1999-01-30 14:24:23 +01:00
|
|
|
break;
|
|
|
|
case STREAM_SEEK_CUR:
|
|
|
|
*plibNewPosition = This->currentPosition;
|
|
|
|
break;
|
|
|
|
case STREAM_SEEK_END:
|
|
|
|
*plibNewPosition = This->streamSize;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return STG_E_INVALIDFUNCTION;
|
|
|
|
}
|
|
|
|
|
2000-10-13 22:26:03 +02:00
|
|
|
plibNewPosition->QuadPart = RtlLargeIntegerAdd( plibNewPosition->QuadPart, dlibMove.QuadPart );
|
1999-01-30 14:24:23 +01:00
|
|
|
|
|
|
|
/*
|
2000-02-25 21:58:25 +01:00
|
|
|
* tell the caller what we calculated
|
1999-01-30 14:24:23 +01:00
|
|
|
*/
|
|
|
|
This->currentPosition = *plibNewPosition;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This method is part of the IStream interface.
|
|
|
|
*
|
|
|
|
* It will change the size of a stream.
|
|
|
|
*
|
|
|
|
* TODO: Switch from small blocks to big blocks and vice versa.
|
|
|
|
*
|
|
|
|
* See the documentation of IStream for more info.
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_SetSize(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
ULARGE_INTEGER libNewSize) /* [in] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
StgStreamImpl* const This=(StgStreamImpl*)iface;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
StgProperty curProperty;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL Success;
|
1999-01-30 14:24:23 +01:00
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
TRACE("(%p, %ld)\n", iface, libNewSize.u.LowPart);
|
1999-05-02 13:41:10 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* As documented.
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
if (libNewSize.u.HighPart != 0)
|
1999-01-30 14:24:23 +01:00
|
|
|
return STG_E_INVALIDFUNCTION;
|
2000-02-25 21:58:25 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Do we have permission?
|
|
|
|
*/
|
|
|
|
if (!(This->grfMode & (STGM_WRITE | STGM_READWRITE)))
|
|
|
|
return STG_E_ACCESSDENIED;
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
if (This->streamSize.u.LowPart == libNewSize.u.LowPart)
|
1999-01-30 14:24:23 +01:00
|
|
|
return S_OK;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This will happen if we're creating a stream
|
|
|
|
*/
|
|
|
|
if ((This->smallBlockChain == 0) && (This->bigBlockChain == 0))
|
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
if (libNewSize.u.LowPart < LIMIT_TO_USE_SMALL_BLOCK)
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
|
|
|
This->smallBlockChain = SmallBlockChainStream_Construct(
|
|
|
|
This->parentStorage->ancestorStorage,
|
|
|
|
This->ownerProperty);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
This->bigBlockChain = BlockChainStream_Construct(
|
|
|
|
This->parentStorage->ancestorStorage,
|
|
|
|
NULL,
|
|
|
|
This->ownerProperty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read this stream's property to see if it's small blocks or big blocks
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
|
1999-01-30 14:24:23 +01:00
|
|
|
This->ownerProperty,
|
2002-06-01 01:06:46 +02:00
|
|
|
&curProperty);
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
1999-02-13 13:10:15 +01:00
|
|
|
* Determine if we have to switch from small to big blocks or vice versa
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
|
|
|
if ( (This->smallBlockChain!=0) &&
|
2004-01-23 02:51:33 +01:00
|
|
|
(curProperty.size.u.LowPart < LIMIT_TO_USE_SMALL_BLOCK) )
|
1999-02-13 13:10:15 +01:00
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
if (libNewSize.u.LowPart >= LIMIT_TO_USE_SMALL_BLOCK)
|
1999-02-13 13:10:15 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Transform the small block chain into a big block chain
|
|
|
|
*/
|
|
|
|
This->bigBlockChain = Storage32Impl_SmallBlocksToBigBlocks(
|
|
|
|
This->parentStorage->ancestorStorage,
|
|
|
|
&This->smallBlockChain);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
if (This->smallBlockChain!=0)
|
|
|
|
{
|
|
|
|
Success = SmallBlockChainStream_SetSize(This->smallBlockChain, libNewSize);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Success = BlockChainStream_SetSize(This->bigBlockChain, libNewSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2002-01-31 22:01:35 +01:00
|
|
|
* Write the new information about this stream to the property
|
1999-01-30 14:24:23 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
Success = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
|
1999-01-30 14:24:23 +01:00
|
|
|
This->ownerProperty,
|
|
|
|
&curProperty);
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
curProperty.size.u.HighPart = libNewSize.u.HighPart;
|
|
|
|
curProperty.size.u.LowPart = libNewSize.u.LowPart;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
if (Success)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
StorageImpl_WriteProperty(This->parentStorage->ancestorStorage,
|
1999-01-30 14:24:23 +01:00
|
|
|
This->ownerProperty,
|
|
|
|
&curProperty);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
This->streamSize = libNewSize;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-04-15 17:47:48 +02:00
|
|
|
/***
|
|
|
|
* This method is part of the IStream interface.
|
|
|
|
*
|
|
|
|
* It will copy the 'cb' Bytes to 'pstm' IStream.
|
|
|
|
*
|
|
|
|
* See the documentation of IStream for more info.
|
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_CopyTo(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
IStream* pstm, /* [unique][in] */
|
|
|
|
ULARGE_INTEGER cb, /* [in] */
|
|
|
|
ULARGE_INTEGER* pcbRead, /* [out] */
|
|
|
|
ULARGE_INTEGER* pcbWritten) /* [out] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-04-15 17:47:48 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
BYTE tmpBuffer[128];
|
|
|
|
ULONG bytesRead, bytesWritten, copySize;
|
|
|
|
ULARGE_INTEGER totalBytesRead;
|
|
|
|
ULARGE_INTEGER totalBytesWritten;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("(%p, %p, %ld, %p, %p)\n",
|
2004-01-23 02:51:33 +01:00
|
|
|
iface, pstm, cb.u.LowPart, pcbRead, pcbWritten);
|
1999-05-02 13:41:10 +02:00
|
|
|
|
1999-04-15 17:47:48 +02:00
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if ( pstm == 0 )
|
|
|
|
return STG_E_INVALIDPOINTER;
|
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
totalBytesRead.u.LowPart = totalBytesRead.u.HighPart = 0;
|
|
|
|
totalBytesWritten.u.LowPart = totalBytesWritten.u.HighPart = 0;
|
1999-04-15 17:47:48 +02:00
|
|
|
|
|
|
|
/*
|
2002-01-31 22:01:35 +01:00
|
|
|
* use stack to store data temporarily
|
|
|
|
* there is surely a more performant way of doing it, for now this basic
|
1999-04-15 17:47:48 +02:00
|
|
|
* implementation will do the job
|
|
|
|
*/
|
2004-01-23 02:51:33 +01:00
|
|
|
while ( cb.u.LowPart > 0 )
|
1999-04-15 17:47:48 +02:00
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
if ( cb.u.LowPart >= 128 )
|
1999-04-15 17:47:48 +02:00
|
|
|
copySize = 128;
|
|
|
|
else
|
2004-01-23 02:51:33 +01:00
|
|
|
copySize = cb.u.LowPart;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 13:41:10 +02:00
|
|
|
IStream_Read(iface, tmpBuffer, copySize, &bytesRead);
|
1999-04-15 17:47:48 +02:00
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
totalBytesRead.u.LowPart += bytesRead;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 13:41:10 +02:00
|
|
|
IStream_Write(pstm, tmpBuffer, bytesRead, &bytesWritten);
|
1999-04-15 17:47:48 +02:00
|
|
|
|
2004-01-23 02:51:33 +01:00
|
|
|
totalBytesWritten.u.LowPart += bytesWritten;
|
1999-04-15 17:47:48 +02:00
|
|
|
|
|
|
|
/*
|
2002-01-31 22:01:35 +01:00
|
|
|
* Check that read & write operations were successful
|
1999-04-15 17:47:48 +02:00
|
|
|
*/
|
1999-05-02 13:41:10 +02:00
|
|
|
if (bytesRead != bytesWritten)
|
1999-04-15 17:47:48 +02:00
|
|
|
{
|
|
|
|
hr = STG_E_MEDIUMFULL;
|
|
|
|
break;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-05-02 13:41:10 +02:00
|
|
|
if (bytesRead!=copySize)
|
2004-01-23 02:51:33 +01:00
|
|
|
cb.u.LowPart = 0;
|
1999-05-02 13:41:10 +02:00
|
|
|
else
|
2004-01-23 02:51:33 +01:00
|
|
|
cb.u.LowPart -= bytesRead;
|
1999-04-15 17:47:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update number of bytes read and written
|
|
|
|
*/
|
|
|
|
if (pcbRead)
|
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
pcbRead->u.LowPart = totalBytesRead.u.LowPart;
|
|
|
|
pcbRead->u.HighPart = totalBytesRead.u.HighPart;
|
1999-04-15 17:47:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pcbWritten)
|
|
|
|
{
|
2004-01-23 02:51:33 +01:00
|
|
|
pcbWritten->u.LowPart = totalBytesWritten.u.LowPart;
|
|
|
|
pcbWritten->u.HighPart = totalBytesWritten.u.HighPart;
|
1999-04-15 17:47:48 +02:00
|
|
|
}
|
|
|
|
return hr;
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This method is part of the IStream interface.
|
|
|
|
*
|
|
|
|
* For streams contained in structured storages, this method
|
|
|
|
* does nothing. This is what the documentation tells us.
|
|
|
|
*
|
|
|
|
* See the documentation of IStream for more info.
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_Commit(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD grfCommitFlags) /* [in] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This method is part of the IStream interface.
|
|
|
|
*
|
|
|
|
* For streams contained in structured storages, this method
|
|
|
|
* does nothing. This is what the documentation tells us.
|
|
|
|
*
|
|
|
|
* See the documentation of IStream for more info.
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_Revert(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface)
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_LockRegion(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
ULARGE_INTEGER libOffset, /* [in] */
|
|
|
|
ULARGE_INTEGER cb, /* [in] */
|
|
|
|
DWORD dwLockType) /* [in] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("not implemented!\n");
|
1999-01-30 14:24:23 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_UnlockRegion(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
ULARGE_INTEGER libOffset, /* [in] */
|
|
|
|
ULARGE_INTEGER cb, /* [in] */
|
|
|
|
DWORD dwLockType) /* [in] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-07-04 18:02:24 +02:00
|
|
|
FIXME("not implemented!\n");
|
1999-01-30 14:24:23 +01:00
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This method is part of the IStream interface.
|
|
|
|
*
|
|
|
|
* This method returns information about the current
|
|
|
|
* stream.
|
|
|
|
*
|
|
|
|
* See the documentation of IStream for more info.
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_Stat(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
1999-01-30 14:24:23 +01:00
|
|
|
STATSTG* pstatstg, /* [out] */
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD grfStatFlag) /* [in] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
1999-02-18 14:26:22 +01:00
|
|
|
StgStreamImpl* const This=(StgStreamImpl*)iface;
|
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
StgProperty curProperty;
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL readSucessful;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
/*
|
|
|
|
* Read the information from the property.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
readSucessful = StorageImpl_ReadProperty(This->parentStorage->ancestorStorage,
|
1999-01-30 14:24:23 +01:00
|
|
|
This->ownerProperty,
|
|
|
|
&curProperty);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
if (readSucessful)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
StorageUtl_CopyPropertyToSTATSTG(pstatstg,
|
|
|
|
&curProperty,
|
1999-01-30 14:24:23 +01:00
|
|
|
grfStatFlag);
|
2000-02-25 21:58:25 +01:00
|
|
|
|
|
|
|
pstatstg->grfMode = This->grfMode;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-01-30 14:24:23 +01:00
|
|
|
return E_FAIL;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-09-11 01:14:39 +02:00
|
|
|
/***
|
|
|
|
* This method is part of the IStream interface.
|
|
|
|
*
|
|
|
|
* This method returns a clone of the interface that allows for
|
|
|
|
* another seek pointer
|
|
|
|
*
|
|
|
|
* See the documentation of IStream for more info.
|
|
|
|
*
|
|
|
|
* I am not totally sure what I am doing here but I presume that this
|
|
|
|
* should be basically as simple as creating a new stream with the same
|
|
|
|
* parent etc and positioning its seek cursor.
|
2002-06-01 01:06:46 +02:00
|
|
|
*/
|
2005-03-31 17:26:30 +02:00
|
|
|
static HRESULT WINAPI StgStreamImpl_Clone(
|
1999-02-26 12:11:13 +01:00
|
|
|
IStream* iface,
|
2002-06-01 01:06:46 +02:00
|
|
|
IStream** ppstm) /* [out] */
|
1999-01-30 14:24:23 +01:00
|
|
|
{
|
2001-09-11 01:14:39 +02:00
|
|
|
StgStreamImpl* const This=(StgStreamImpl*)iface;
|
|
|
|
HRESULT hres;
|
|
|
|
StgStreamImpl* new_stream;
|
|
|
|
LARGE_INTEGER seek_pos;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Sanity check
|
|
|
|
*/
|
|
|
|
if ( ppstm == 0 )
|
|
|
|
return STG_E_INVALIDPOINTER;
|
|
|
|
|
|
|
|
new_stream = StgStreamImpl_Construct (This->parentStorage, This->grfMode, This->ownerProperty);
|
|
|
|
|
|
|
|
if (!new_stream)
|
|
|
|
return STG_E_INSUFFICIENTMEMORY; /* Currently the only reason for new_stream=0 */
|
|
|
|
|
|
|
|
*ppstm = (IStream*) new_stream;
|
|
|
|
seek_pos.QuadPart = This->currentPosition.QuadPart;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-09-11 01:14:39 +02:00
|
|
|
hres=StgStreamImpl_Seek (*ppstm, seek_pos, STREAM_SEEK_SET, NULL);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2001-09-11 01:14:39 +02:00
|
|
|
assert (SUCCEEDED(hres));
|
|
|
|
|
|
|
|
return S_OK;
|
1999-01-30 14:24:23 +01:00
|
|
|
}
|
2005-03-31 17:26:30 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Virtual function table for the StgStreamImpl class.
|
|
|
|
*/
|
2005-06-06 21:50:35 +02:00
|
|
|
static const IStreamVtbl StgStreamImpl_Vtbl =
|
2005-03-31 17:26:30 +02:00
|
|
|
{
|
|
|
|
StgStreamImpl_QueryInterface,
|
|
|
|
StgStreamImpl_AddRef,
|
|
|
|
StgStreamImpl_Release,
|
|
|
|
StgStreamImpl_Read,
|
|
|
|
StgStreamImpl_Write,
|
|
|
|
StgStreamImpl_Seek,
|
|
|
|
StgStreamImpl_SetSize,
|
|
|
|
StgStreamImpl_CopyTo,
|
|
|
|
StgStreamImpl_Commit,
|
|
|
|
StgStreamImpl_Revert,
|
|
|
|
StgStreamImpl_LockRegion,
|
|
|
|
StgStreamImpl_UnlockRegion,
|
|
|
|
StgStreamImpl_Stat,
|
|
|
|
StgStreamImpl_Clone
|
|
|
|
};
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
** StgStreamImpl implementation
|
|
|
|
*/
|
|
|
|
|
|
|
|
/***
|
|
|
|
* This is the constructor for the StgStreamImpl class.
|
|
|
|
*
|
|
|
|
* Params:
|
|
|
|
* parentStorage - Pointer to the storage that contains the stream to open
|
|
|
|
* ownerProperty - Index of the property that points to this stream.
|
|
|
|
*/
|
|
|
|
StgStreamImpl* StgStreamImpl_Construct(
|
|
|
|
StorageBaseImpl* parentStorage,
|
|
|
|
DWORD grfMode,
|
|
|
|
ULONG ownerProperty)
|
|
|
|
{
|
|
|
|
StgStreamImpl* newStream;
|
|
|
|
|
|
|
|
newStream = HeapAlloc(GetProcessHeap(), 0, sizeof(StgStreamImpl));
|
|
|
|
|
|
|
|
if (newStream!=0)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Set-up the virtual function table and reference count.
|
|
|
|
*/
|
|
|
|
newStream->lpVtbl = &StgStreamImpl_Vtbl;
|
|
|
|
newStream->ref = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to nail-down the reference to the storage in case the
|
|
|
|
* stream out-lives the storage in the client application.
|
|
|
|
*/
|
|
|
|
newStream->parentStorage = parentStorage;
|
|
|
|
IStorage_AddRef((IStorage*)newStream->parentStorage);
|
|
|
|
|
|
|
|
newStream->grfMode = grfMode;
|
|
|
|
newStream->ownerProperty = ownerProperty;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the stream at the beginning.
|
|
|
|
*/
|
|
|
|
newStream->currentPosition.u.HighPart = 0;
|
|
|
|
newStream->currentPosition.u.LowPart = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the rest of the data.
|
|
|
|
*/
|
|
|
|
newStream->streamSize.u.HighPart = 0;
|
|
|
|
newStream->streamSize.u.LowPart = 0;
|
|
|
|
newStream->bigBlockChain = 0;
|
|
|
|
newStream->smallBlockChain = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Read the size from the property and determine if the blocks forming
|
|
|
|
* this stream are large or small.
|
|
|
|
*/
|
|
|
|
StgStreamImpl_OpenBlockChain(newStream);
|
|
|
|
}
|
|
|
|
|
|
|
|
return newStream;
|
|
|
|
}
|