Piotr Caban : scrrun: Add IFile::get_Size implementation.

Alexandre Julliard julliard at winehq.org
Tue Jul 30 14:14:21 CDT 2013


Module: wine
Branch: master
Commit: c7abcd74fc9a1cbe56059a31b2af02106efefa6a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c7abcd74fc9a1cbe56059a31b2af02106efefa6a

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue Jul 30 11:31:19 2013 +0200

scrrun: Add IFile::get_Size implementation.

---

 dlls/scrrun/filesystem.c       |   24 ++++++++++++++++++++++--
 dlls/scrrun/tests/filesystem.c |    6 ++++++
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index 1074ea5..c4aa4b8 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -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)
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index cc94a82..0a55736 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -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);




More information about the wine-cvs mailing list