From f6016609e1709acf8a843bc714bc7ff8e22f2908 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 21 Apr 2017 12:26:49 +0300 Subject: [PATCH] scrrun: Added DateLastModified property for IFile. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/scrrun/filesystem.c | 27 ++++++++++++++++++++++++--- dlls/scrrun/tests/filesystem.c | 9 +++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 45040b36a12..2acef849fa5 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -2712,6 +2712,21 @@ static HRESULT WINAPI file_put_Attributes(IFile *iface, FileAttribute pfa) return SetFileAttributesW(This->path, pfa) ? S_OK : create_error(GetLastError()); } +static HRESULT get_date_from_filetime(const FILETIME *ft, DATE *date) +{ + FILETIME ftlocal; + SYSTEMTIME st; + + if (!date) + return E_POINTER; + + FileTimeToLocalFileTime(ft, &ftlocal); + FileTimeToSystemTime(&ftlocal, &st); + SystemTimeToVariantTime(&st, date); + + return S_OK; +} + static HRESULT WINAPI file_get_DateCreated(IFile *iface, DATE *pdate) { struct file *This = impl_from_IFile(iface); @@ -2719,11 +2734,17 @@ static HRESULT WINAPI file_get_DateCreated(IFile *iface, DATE *pdate) return E_NOTIMPL; } -static HRESULT WINAPI file_get_DateLastModified(IFile *iface, DATE *pdate) +static HRESULT WINAPI file_get_DateLastModified(IFile *iface, DATE *date) { struct file *This = impl_from_IFile(iface); - FIXME("(%p)->(%p)\n", This, pdate); - return E_NOTIMPL; + WIN32_FILE_ATTRIBUTE_DATA attrs; + + TRACE("(%p)->(%p)\n", This, date); + + if (GetFileAttributesExW(This->path, GetFileExInfoStandard, &attrs)) + return get_date_from_filetime(&attrs.ftLastWriteTime, date); + + return E_FAIL; } static HRESULT WINAPI file_get_DateLastAccessed(IFile *iface, DATE *pdate) diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index bb926c2c4b4..2e3406d3ceb 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -624,6 +624,7 @@ static void test_GetFile(void) HRESULT hr; HANDLE hf; BOOL ret; + DATE date; get_temp_path(NULL, pathW); @@ -649,6 +650,14 @@ static void test_GetFile(void) hr = IFileSystem3_GetFile(fs3, path, &file); ok(hr == S_OK, "GetFile returned %x, expected S_OK\n", hr); + hr = IFile_get_DateLastModified(file, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + + date = 0.0; + hr = IFile_get_DateLastModified(file, &date); + ok(hr == S_OK, "got 0x%08x\n", hr); + ok(date > 0.0, "got %f\n", date); + hr = IFile_get_Path(file, NULL); ok(hr == E_POINTER, "got 0x%08x\n", hr);