Huw Davies : ole32: Add a helper function to return the file size and modify EnsureExists to use it .
Alexandre Julliard
julliard at winehq.org
Wed Jan 28 08:03:11 CST 2009
Module: wine
Branch: master
Commit: bfc32ae0c615b12dd61fe7c2b444f1b4ff5e2dda
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bfc32ae0c615b12dd61fe7c2b444f1b4ff5e2dda
Author: Huw Davies <huw at codeweavers.com>
Date: Tue Jan 27 17:13:28 2009 +0000
ole32: Add a helper function to return the file size and modify EnsureExists to use it.
---
dlls/ole32/stg_bigblockfile.c | 37 +++++++++++++++++++++++++++++--------
dlls/ole32/storage32.h | 4 ++--
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/dlls/ole32/stg_bigblockfile.c b/dlls/ole32/stg_bigblockfile.c
index 24d8d95..1ab3369 100644
--- a/dlls/ole32/stg_bigblockfile.c
+++ b/dlls/ole32/stg_bigblockfile.c
@@ -827,10 +827,12 @@ HRESULT BIGBLOCKFILE_WriteAt(BigBlockFile *This, ULARGE_INTEGER offset,
* Sets the size of the file.
*
*/
-void BIGBLOCKFILE_SetSize(BigBlockFile *This, ULARGE_INTEGER newSize)
+HRESULT BIGBLOCKFILE_SetSize(BigBlockFile *This, ULARGE_INTEGER newSize)
{
+ HRESULT hr = S_OK;
+
if (This->filesize.u.LowPart == newSize.u.LowPart)
- return;
+ return hr;
TRACE("from %u to %u\n", This->filesize.u.LowPart, newSize.u.LowPart);
@@ -882,6 +884,20 @@ void BIGBLOCKFILE_SetSize(BigBlockFile *This, ULARGE_INTEGER newSize)
This->filesize.u.HighPart = newSize.u.HighPart;
BIGBLOCKFILE_RemapAllMappedPages(This);
+ return hr;
+}
+
+/******************************************************************************
+ * BIGBLOCKFILE_GetSize
+ *
+ * Gets the size of the file.
+ *
+ */
+static HRESULT BIGBLOCKFILE_GetSize(BigBlockFile *This, ULARGE_INTEGER *size)
+{
+ HRESULT hr = S_OK;
+ *size = This->filesize;
+ return hr;
}
/******************************************************************************
@@ -889,22 +905,27 @@ void BIGBLOCKFILE_SetSize(BigBlockFile *This, ULARGE_INTEGER newSize)
*
* Grows the file if necessary to make sure the block is valid.
*/
-void BIGBLOCKFILE_EnsureExists(BigBlockFile *This, ULONG index)
+HRESULT BIGBLOCKFILE_EnsureExists(BigBlockFile *This, ULONG index)
{
+ ULARGE_INTEGER size;
+ HRESULT hr;
+
/* Block index starts at -1 translate to zero based index */
if (index == 0xffffffff)
index = 0;
else
index++;
+ hr = BIGBLOCKFILE_GetSize(This, &size);
+ if(FAILED(hr)) return hr;
+
/* make sure that the block physically exists */
- if ((This->blocksize * (index + 1)) > This->filesize.u.LowPart)
+ if ((This->blocksize * (index + 1)) > size.QuadPart)
{
ULARGE_INTEGER newSize;
- newSize.u.HighPart = 0;
- newSize.u.LowPart = This->blocksize * (index + 1);
-
- BIGBLOCKFILE_SetSize(This, newSize);
+ newSize.QuadPart = This->blocksize * (index + 1);
+ hr = BIGBLOCKFILE_SetSize(This, newSize);
}
+ return hr;
}
diff --git a/dlls/ole32/storage32.h b/dlls/ole32/storage32.h
index 639ec6a..1e40b3a 100644
--- a/dlls/ole32/storage32.h
+++ b/dlls/ole32/storage32.h
@@ -164,8 +164,8 @@ BigBlockFile* BIGBLOCKFILE_Construct(HANDLE hFile,
ULONG blocksize,
BOOL fileBased);
void BIGBLOCKFILE_Destructor(LPBIGBLOCKFILE This);
-void BIGBLOCKFILE_EnsureExists(LPBIGBLOCKFILE This, ULONG index);
-void BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize);
+HRESULT BIGBLOCKFILE_EnsureExists(LPBIGBLOCKFILE This, ULONG index);
+HRESULT BIGBLOCKFILE_SetSize(LPBIGBLOCKFILE This, ULARGE_INTEGER newSize);
HRESULT BIGBLOCKFILE_ReadAt(LPBIGBLOCKFILE This, ULARGE_INTEGER offset,
void* buffer, ULONG size, ULONG* bytesRead);
HRESULT BIGBLOCKFILE_WriteAt(LPBIGBLOCKFILE This, ULARGE_INTEGER offset,
More information about the wine-cvs
mailing list