Commit c7abcd74 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

scrrun: Add IFile::get_Size implementation.

parent 4135874f
......@@ -20,6 +20,7 @@
#include "config.h"
#include <stdarg.h>
#include <limits.h>
#include "windef.h"
#include "winbase.h"
......@@ -824,8 +825,27 @@ static HRESULT WINAPI file_get_DateLastAccessed(IFile *iface, DATE *pdate)
static HRESULT WINAPI file_get_Size(IFile *iface, VARIANT *pvarSize)
{
struct file *This = impl_from_IFile(iface);
FIXME("(%p)->(%p)\n", This, pvarSize);
return E_NOTIMPL;
WIN32_FIND_DATAW fd;
HANDLE f;
TRACE("(%p)->(%p)\n", This, pvarSize);
if(!pvarSize)
return E_POINTER;
f = FindFirstFileW(This->path, &fd);
if(f == INVALID_HANDLE_VALUE)
return create_error(GetLastError());
FindClose(f);
if(fd.nFileSizeHigh || fd.nFileSizeLow>INT_MAX) {
V_VT(pvarSize) = VT_R8;
V_R8(pvarSize) = ((ULONGLONG)fd.nFileSizeHigh<<32) + fd.nFileSizeLow;
}else {
V_VT(pvarSize) = VT_I4;
V_I4(pvarSize) = fd.nFileSizeLow;
}
return S_OK;
}
static HRESULT WINAPI file_get_Type(IFile *iface, BSTR *pbstrType)
......
......@@ -467,6 +467,7 @@ static void test_GetFile(void)
BSTR path = SysAllocString(get_file);
FileAttribute fa;
VARIANT size;
DWORD gfa;
IFile *file;
HRESULT hr;
......@@ -505,6 +506,11 @@ static void test_GetFile(void)
gfa = GetFileAttributesW(get_file) & ~FILE_ATTRIBUTE_NORMAL;
ok(hr == S_OK, "get_Attributes returned %x, expected S_OK\n", hr);
ok(fa == gfa, "fa = %x, expected %x\n", fa, gfa);
hr = IFile_get_Size(file, &size);
ok(hr == S_OK, "get_Size returned %x, expected S_OK\n", hr);
ok(V_VT(&size) == VT_I4, "V_VT(&size) = %d, expected VT_I4\n", V_VT(&size));
ok(V_I4(&size) == 0, "V_I4(&size) = %d, expected 0\n", V_I4(&size));
IFile_Release(file);
DeleteFileW(path);
......
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