From: Francis De Brabandere <francisdb@gmail.com> Wrap MoveFileW on the stored path. --- dlls/scrrun/filesystem.c | 9 ++++++-- dlls/scrrun/tests/filesystem.c | 41 ++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index e841795de97..3c246c6c2f7 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -3197,8 +3197,13 @@ static HRESULT WINAPI file_Copy(IFile *iface, BSTR Destination, VARIANT_BOOL Ove static HRESULT WINAPI file_Move(IFile *iface, BSTR Destination) { struct file *This = impl_from_IFile(iface); - FIXME("(%p)->(%s)\n", This, debugstr_w(Destination)); - return E_NOTIMPL; + + TRACE("(%p)->(%s)\n", This, debugstr_w(Destination)); + + if (!MoveFileW(This->path, Destination)) + return create_error(GetLastError()); + + return S_OK; } static HRESULT WINAPI file_OpenAsTextStream(IFile *iface, IOMode mode, Tristate format, ITextStream **stream) diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index 4c30f327aeb..5bf3a860988 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -3194,6 +3194,46 @@ static void test_File_Delete(void) SysFreeString(path); } +static void test_File_Move(void) +{ + WCHAR src_path[MAX_PATH], dst_path[MAX_PATH]; + IFile *file; + BSTR path, dst; + HRESULT hr; + HANDLE hf; + DWORD attrs; + + get_temp_path(NULL, src_path); + hf = CreateFileW(src_path, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL); + if (hf == INVALID_HANDLE_VALUE) + { + skip("Can't create temporary file\n"); + return; + } + CloseHandle(hf); + + get_temp_path(NULL, dst_path); + + path = SysAllocString(src_path); + hr = IFileSystem3_GetFile(fs3, path, &file); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + dst = SysAllocString(dst_path); + hr = IFile_Move(file, dst); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + + attrs = GetFileAttributesW(src_path); + ok(attrs == INVALID_FILE_ATTRIBUTES, "source file should be gone\n"); + + attrs = GetFileAttributesW(dst_path); + ok(attrs != INVALID_FILE_ATTRIBUTES, "destination file should exist\n"); + + IFile_Release(file); + SysFreeString(path); + SysFreeString(dst); + DeleteFileW(dst_path); +} + static void test_Folder_Delete(void) { WCHAR temp_path[MAX_PATH], dir_path[MAX_PATH], file_path[MAX_PATH]; @@ -3310,6 +3350,7 @@ START_TEST(filesystem) test_MoveFolder(); test_File_Delete(); test_Folder_Delete(); + test_File_Move(); test_DoOpenPipeStream(); IFileSystem3_Release(fs3); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10680