Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/scrrun/filesystem.c | 21 +++++++++++++++++----
dlls/scrrun/tests/filesystem.c | 34 ++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 4 deletions(-)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index aa1660085e..daac75f1e1 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -3596,12 +3596,25 @@ static HRESULT WINAPI filesys_DeleteFolder(IFileSystem3 *iface, BSTR FolderSpec,
return delete_folder(FolderSpec, SysStringLen(FolderSpec), Force);
}
-static HRESULT WINAPI filesys_MoveFile(IFileSystem3 *iface, BSTR Source,
- BSTR Destination)
+static HRESULT WINAPI filesys_MoveFile(IFileSystem3 *iface, BSTR src, BSTR dest)
{
- FIXME("%p %s %s\n", iface, debugstr_w(Source), debugstr_w(Destination));
+ DWORD error;
- return E_NOTIMPL;
+ TRACE("%p %s %s\n", iface, debugstr_w(src), debugstr_w(dest));
+
+ if (MoveFileW(src, dest))
+ return S_OK;
+
+ error = GetLastError();
+ switch (error)
+ {
+ case ERROR_ALREADY_EXISTS:
+ return CTL_E_FILEALREADYEXISTS;
+ case ERROR_FILE_NOT_FOUND:
+ return CTL_E_FILENOTFOUND;
+ default:
+ return HRESULT_FROM_WIN32(error);
+ }
}
static HRESULT WINAPI filesys_MoveFolder(IFileSystem3 *iface,BSTR Source,
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index 29ee73f243..925a889a3a 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -2217,6 +2217,39 @@ static void test_GetSpecialFolder(void)
IFolder_Release(folder);
}
+static void test_MoveFile(void)
+{
+ WCHAR source[MAX_PATH], dest[MAX_PATH], tempdir[MAX_PATH];
+ static const WCHAR prefixW[] = {'p','f','x',0};
+ BSTR str1, str2;
+ HRESULT hr;
+ DWORD ret;
+
+ ret = GetTempPathW(ARRAY_SIZE(tempdir), tempdir);
+ ok(ret != 0, "Failed to get temp path, error %d\n", GetLastError());
+
+ ret = GetTempFileNameW(tempdir, prefixW, 0, source);
+ ok(ret != 0, "Failed to get temp name, error %d\n", GetLastError());
+
+ ret = GetTempFileNameW(tempdir, prefixW, 0, dest);
+ ok(ret != 0, "Failed to get temp name, error %d\n", GetLastError());
+
+ str1 = SysAllocString(source);
+ str2 = SysAllocString(dest);
+
+ hr = IFileSystem3_MoveFile(fs3, str1, str2);
+ ok(hr == CTL_E_FILEALREADYEXISTS, "Unexpected hr %#x.\n", hr);
+
+ DeleteFileW(source);
+ DeleteFileW(dest);
+
+ hr = IFileSystem3_MoveFile(fs3, str1, str2);
+ ok(hr == CTL_E_FILENOTFOUND, "Unexpected hr %#x.\n", hr);
+
+ SysFreeString(str1);
+ SysFreeString(str2);
+}
+
START_TEST(filesystem)
{
HRESULT hr;
@@ -2255,6 +2288,7 @@ START_TEST(filesystem)
test_SerialNumber();
test_GetExtensionName();
test_GetSpecialFolder();
+ test_MoveFile();
IFileSystem3_Release(fs3);
--
2.18.0