From: Francis De Brabandere <francisdb@gmail.com> Implement IFolder::get_DateCreated, IFolder::get_DateLastModified, IFolder::get_DateLastAccessed, and the previously-stubbed IFile::get_DateLastAccessed, all delegating to GetFileAttributesExW and the existing get_date_from_filetime helper. --- dlls/scrrun/filesystem.c | 41 +++++++++++++++++++++------ dlls/scrrun/tests/filesystem.c | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 8 deletions(-) diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 75f52501b6c..af76f0cf4d8 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -199,6 +199,7 @@ static HRESULT create_foldercoll_enum(struct foldercollection*, IUnknown**); static HRESULT create_filecoll_enum(struct filecollection*, IUnknown**); static HRESULT create_drivecoll_enum(struct drivecollection*, IUnknown**); static inline DWORD get_parent_folder_name(const WCHAR *path, DWORD len); +static HRESULT get_date_from_filetime(const FILETIME *ft, DATE *date); static inline BOOL is_dir_data(const WIN32_FIND_DATAW *data) { @@ -2620,22 +2621,40 @@ static HRESULT WINAPI folder_put_Attributes(IFolder *iface, FileAttribute attr) static HRESULT WINAPI folder_get_DateCreated(IFolder *iface, DATE *date) { struct folder *This = impl_from_IFolder(iface); - FIXME("(%p)->(%p): stub\n", This, date); - 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.ftCreationTime, date); + + return E_FAIL; } static HRESULT WINAPI folder_get_DateLastModified(IFolder *iface, DATE *date) { struct folder *This = impl_from_IFolder(iface); - FIXME("(%p)->(%p): stub\n", This, date); - 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 folder_get_DateLastAccessed(IFolder *iface, DATE *date) { struct folder *This = impl_from_IFolder(iface); - FIXME("(%p)->(%p): stub\n", This, date); - 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.ftLastAccessTime, date); + + return E_FAIL; } static HRESULT WINAPI folder_get_Type(IFolder *iface, BSTR *type) @@ -3081,8 +3100,14 @@ static HRESULT WINAPI file_get_DateLastModified(IFile *iface, DATE *date) static HRESULT WINAPI file_get_DateLastAccessed(IFile *iface, DATE *pdate) { 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, pdate); + + if (GetFileAttributesExW(This->path, GetFileExInfoStandard, &attrs)) + return get_date_from_filetime(&attrs.ftLastAccessTime, pdate); + + return E_FAIL; } static HRESULT WINAPI file_get_Size(IFile *iface, VARIANT *pvarSize) diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index 14db34b8d02..9b5abdf5c97 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -704,6 +704,14 @@ static void test_GetFile(void) ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(date > 0.0, "got %f\n", date); + hr = IFile_get_DateLastAccessed(file, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + + date = 0.0; + hr = IFile_get_DateLastAccessed(file, &date); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(date > 0.0, "got %f\n", date); + hr = IFile_get_Path(file, NULL); ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); @@ -1077,6 +1085,49 @@ static void test_GetFolder(void) SetCurrentDirectoryW(prev_path); } +static void test_Folder_Dates(void) +{ + WCHAR temp_path[MAX_PATH], dir_path[MAX_PATH]; + IFolder *folder; + BSTR path; + DATE date; + HRESULT hr; + + GetTempPathW(MAX_PATH, temp_path); + lstrcpyW(dir_path, temp_path); + lstrcatW(dir_path, L"scrrun_dates_test"); + ok(CreateDirectoryW(dir_path, NULL), "CreateDirectory failed, error %ld\n", GetLastError()); + + path = SysAllocString(dir_path); + hr = IFileSystem3_GetFolder(fs3, path, &folder); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + hr = IFolder_get_DateCreated(folder, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + date = 0.0; + hr = IFolder_get_DateCreated(folder, &date); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(date > 0.0, "got %f\n", date); + + hr = IFolder_get_DateLastModified(folder, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + date = 0.0; + hr = IFolder_get_DateLastModified(folder, &date); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(date > 0.0, "got %f\n", date); + + hr = IFolder_get_DateLastAccessed(folder, NULL); + ok(hr == E_POINTER, "Unexpected hr %#lx.\n", hr); + date = 0.0; + hr = IFolder_get_DateLastAccessed(folder, &date); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + ok(date > 0.0, "got %f\n", date); + + IFolder_Release(folder); + SysFreeString(path); + RemoveDirectoryW(dir_path); +} + static void test_Folder_Attributes(void) { static const DWORD attr_mask = FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | @@ -3113,6 +3164,7 @@ START_TEST(filesystem) test_BuildPath(); test_GetFolder(); test_Folder_Attributes(); + test_Folder_Dates(); test_Folder_ParentFolder(); test_FolderCollection(); test_FileCollection(); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10661