Nikolay Sivov : scrrun: Added DateLastModified property for IFile.
Alexandre Julliard
julliard at winehq.org
Fri Apr 21 15:18:16 CDT 2017
Module: wine
Branch: master
Commit: f6016609e1709acf8a843bc714bc7ff8e22f2908
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f6016609e1709acf8a843bc714bc7ff8e22f2908
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Fri Apr 21 12:26:49 2017 +0300
scrrun: Added DateLastModified property for IFile.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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 45040b3..2acef84 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 bb926c2..2e3406d 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);
More information about the wine-cvs
mailing list