Commit d32abd77 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

ole32: Don't store file size in FileLockBytesImpl.

parent 5a8d7328
...@@ -49,7 +49,6 @@ typedef struct FileLockBytesImpl ...@@ -49,7 +49,6 @@ typedef struct FileLockBytesImpl
{ {
ILockBytes ILockBytes_iface; ILockBytes ILockBytes_iface;
LONG ref; LONG ref;
ULARGE_INTEGER filesize;
HANDLE hfile; HANDLE hfile;
DWORD flProtect; DWORD flProtect;
LPWSTR pwcsName; LPWSTR pwcsName;
...@@ -108,8 +107,6 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN ...@@ -108,8 +107,6 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN
This->ILockBytes_iface.lpVtbl = &FileLockBytesImpl_Vtbl; This->ILockBytes_iface.lpVtbl = &FileLockBytesImpl_Vtbl;
This->ref = 1; This->ref = 1;
This->hfile = hFile; This->hfile = hFile;
This->filesize.u.LowPart = GetFileSize(This->hfile,
&This->filesize.u.HighPart);
This->flProtect = GetProtectMode(openFlags); This->flProtect = GetProtectMode(openFlags);
if(pwcsName) { if(pwcsName) {
...@@ -129,8 +126,6 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN ...@@ -129,8 +126,6 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN
else else
This->pwcsName = NULL; This->pwcsName = NULL;
TRACE("file len %u\n", This->filesize.u.LowPart);
*pLockBytes = &This->ILockBytes_iface; *pLockBytes = &This->ILockBytes_iface;
return S_OK; return S_OK;
...@@ -248,7 +243,6 @@ static HRESULT WINAPI FileLockBytesImpl_WriteAt( ...@@ -248,7 +243,6 @@ static HRESULT WINAPI FileLockBytesImpl_WriteAt(
ULONG* pcbWritten) /* [out] */ ULONG* pcbWritten) /* [out] */
{ {
FileLockBytesImpl* This = impl_from_ILockBytes(iface); FileLockBytesImpl* This = impl_from_ILockBytes(iface);
ULONG size_needed = ulOffset.u.LowPart + cb;
ULONG bytes_left = cb; ULONG bytes_left = cb;
const BYTE *writePtr = pv; const BYTE *writePtr = pv;
BOOL ret; BOOL ret;
...@@ -266,14 +260,6 @@ static HRESULT WINAPI FileLockBytesImpl_WriteAt( ...@@ -266,14 +260,6 @@ static HRESULT WINAPI FileLockBytesImpl_WriteAt(
if (pcbWritten) if (pcbWritten)
*pcbWritten = 0; *pcbWritten = 0;
if (size_needed > This->filesize.u.LowPart)
{
ULARGE_INTEGER newSize;
newSize.u.HighPart = 0;
newSize.u.LowPart = size_needed;
ILockBytes_SetSize(iface, newSize);
}
offset.QuadPart = ulOffset.QuadPart; offset.QuadPart = ulOffset.QuadPart;
ret = SetFilePointerEx(This->hfile, offset, NULL, FILE_BEGIN); ret = SetFilePointerEx(This->hfile, offset, NULL, FILE_BEGIN);
...@@ -316,10 +302,7 @@ static HRESULT WINAPI FileLockBytesImpl_SetSize(ILockBytes* iface, ULARGE_INTEGE ...@@ -316,10 +302,7 @@ static HRESULT WINAPI FileLockBytesImpl_SetSize(ILockBytes* iface, ULARGE_INTEGE
HRESULT hr = S_OK; HRESULT hr = S_OK;
LARGE_INTEGER newpos; LARGE_INTEGER newpos;
if (This->filesize.u.LowPart == newSize.u.LowPart) TRACE("new size %u\n", newSize.u.LowPart);
return hr;
TRACE("from %u to %u\n", This->filesize.u.LowPart, newSize.u.LowPart);
newpos.QuadPart = newSize.QuadPart; newpos.QuadPart = newSize.QuadPart;
if (SetFilePointerEx(This->hfile, newpos, NULL, FILE_BEGIN)) if (SetFilePointerEx(This->hfile, newpos, NULL, FILE_BEGIN))
...@@ -327,7 +310,6 @@ static HRESULT WINAPI FileLockBytesImpl_SetSize(ILockBytes* iface, ULARGE_INTEGE ...@@ -327,7 +310,6 @@ static HRESULT WINAPI FileLockBytesImpl_SetSize(ILockBytes* iface, ULARGE_INTEGE
SetEndOfFile(This->hfile); SetEndOfFile(This->hfile);
} }
This->filesize = newSize;
return hr; return hr;
} }
...@@ -412,7 +394,8 @@ static HRESULT WINAPI FileLockBytesImpl_Stat(ILockBytes* iface, ...@@ -412,7 +394,8 @@ static HRESULT WINAPI FileLockBytesImpl_Stat(ILockBytes* iface,
pstatstg->pwcsName = NULL; pstatstg->pwcsName = NULL;
pstatstg->type = STGTY_LOCKBYTES; pstatstg->type = STGTY_LOCKBYTES;
pstatstg->cbSize = This->filesize;
pstatstg->cbSize.u.LowPart = GetFileSize(This->hfile, &pstatstg->cbSize.u.HighPart);
/* FIXME: If the implementation is exported, we'll need to set other fields. */ /* FIXME: If the implementation is exported, we'll need to set other fields. */
return S_OK; return S_OK;
......
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