[PATCH] scrrun: Added DateLastModified property for IFile
Nikolay Sivov
nsivov at codeweavers.com
Fri Apr 21 04:26:49 CDT 2017
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
For https://bugs.winehq.org/show_bug.cgi?id=42857
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 45040b36a1..2acef849fa 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 bb926c2c4b..2e3406d3ce 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);
--
2.11.0
More information about the wine-patches
mailing list