Paul Gofman : quartz/filesource: Store file size on load.

Alexandre Julliard julliard at winehq.org
Mon Apr 20 15:48:20 CDT 2020


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

Author: Paul Gofman <pgofman at codeweavers.com>
Date:   Mon Apr 20 03:53:20 2020 +0300

quartz/filesource: Store file size on load.

Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/quartz/filesource.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/dlls/quartz/filesource.c b/dlls/quartz/filesource.c
index 3b19d6e7df..8983f7317b 100644
--- a/dlls/quartz/filesource.c
+++ b/dlls/quartz/filesource.c
@@ -64,6 +64,7 @@ struct async_reader
     LPOLESTR pszFileName;
     AM_MEDIA_TYPE mt;
     HANDLE file, port, io_thread;
+    LARGE_INTEGER file_size;
     CRITICAL_SECTION sample_cs;
     BOOL flushing;
     struct request *requests;
@@ -474,6 +475,12 @@ static HRESULT WINAPI FileSource_Load(IFileSourceFilter * iface, LPCOLESTR pszFi
         return HRESULT_FROM_WIN32(GetLastError());
     }
 
+    if (!GetFileSizeEx(hFile, &This->file_size))
+    {
+        WARN("Could not get file size.\n");
+        return HRESULT_FROM_WIN32(GetLastError());
+    }
+
     if (This->pszFileName)
     {
         free(This->pszFileName);
@@ -883,14 +890,10 @@ static HRESULT WINAPI FileAsyncReader_SyncRead(IAsyncReader *iface,
 static HRESULT WINAPI FileAsyncReader_Length(IAsyncReader *iface, LONGLONG *total, LONGLONG *available)
 {
     struct async_reader *filter = impl_from_IAsyncReader(iface);
-    DWORD low, high;
 
     TRACE("iface %p, total %p, available %p.\n", iface, total, available);
 
-    if ((low = GetFileSize(filter->file, &high)) == -1 && GetLastError() != NO_ERROR)
-        return HRESULT_FROM_WIN32(GetLastError());
-
-    *available = *total = (LONGLONG)low | (LONGLONG)high << (sizeof(DWORD) * 8);
+    *available = *total = filter->file_size.QuadPart;
 
     return S_OK;
 }




More information about the wine-cvs mailing list