From: Robert Wilhelm robert.wilhelm@gmx.net
Signed-off-by: Robert Wilhelm robert.wilhelm@gmx.net --- dlls/scrrun/filesystem.c | 16 ++++++++++++-- dlls/scrrun/tests/filesystem.c | 38 +++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 3 deletions(-)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index a7488454e95..feaf7968a60 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -3781,18 +3781,30 @@ static inline HRESULT create_movefolder_error(DWORD err)
static HRESULT WINAPI filesys_MoveFolder(IFileSystem3 *iface, BSTR source, BSTR destination) { - int len; - WCHAR src_path[MAX_PATH]; + int len, dst_len; + WCHAR src_path[MAX_PATH], dst_path[MAX_PATH]; + WCHAR *filename;
TRACE("%p %s %s\n", iface, debugstr_w(source), debugstr_w(destination));
if(!source || !source[0] || !destination || !destination[0]) return E_INVALIDARG;
+ if (!GetFullPathNameW(source, MAX_PATH, src_path, &filename)) + return E_FAIL; + len = SysStringLen(source); lstrcpyW(src_path, source); if (source[len-1] != '\' && source[len-1] != '/') wcscat(src_path, L"\");
+ dst_len = lstrlenW(destination); + if (destination[dst_len-1] == '\' || destination[dst_len-1] == '/') { + lstrcpyW(dst_path, destination); + lstrcatW(dst_path, filename); + TRACE("move %s to %s\n", debugstr_w(src_path), debugstr_w(dst_path)); + return MoveFileW(src_path, dst_path) ? S_OK : create_movefolder_error(GetLastError()); + } + TRACE("move %s to %s\n", debugstr_w(src_path), debugstr_w(destination)); return MoveFileW(src_path, destination) ? S_OK : create_movefolder_error(GetLastError()); }
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index 91c265b2ace..96d1bdfffcb 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -2603,7 +2603,7 @@ static void test_MoveFile(void) static void test_MoveFolder(void) { BSTR src, dst, str, empty; - WCHAR buffW1[MAX_PATH],buffW2[MAX_PATH]; + WCHAR buffW1[MAX_PATH],buffW2[MAX_PATH],pathW[MAX_PATH]; HRESULT hr; HANDLE file;
@@ -2662,6 +2662,42 @@ static void test_MoveFolder(void) SysFreeString(src); SysFreeString(dst); DeleteFileW(buffW1); + + GetTempPathW(MAX_PATH, buffW1); + lstrcatW(buffW1,L"foo"); + GetTempPathW(MAX_PATH, buffW2); + lstrcatW(buffW2,L"bar"); + ok(CreateDirectoryW(buffW1, NULL), "CreateDirectory(%s) failed\n", wine_dbgstr_w(buffW1)); + ok(CreateDirectoryW(buffW2, NULL), "CreateDirectory(%s) failed\n", wine_dbgstr_w(buffW2)); + lstrcpyW(pathW,buffW2); + lstrcatW(pathW,L"\"); + src = SysAllocString(buffW1); + dst = SysAllocString(pathW); + hr = IFileSystem3_MoveFolder(fs3, src, dst); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + SysFreeString(src); + SysFreeString(dst); + lstrcatW(pathW,L"foo"); + ok(RemoveDirectoryW(pathW), "can't remove %s directory\n", wine_dbgstr_w(pathW)); + ok(RemoveDirectoryW(buffW2), "can't remove %s directory\n", wine_dbgstr_w(buffW2)); + + GetTempPathW(MAX_PATH, buffW1); + lstrcatW(buffW1,L"foo"); + GetTempPathW(MAX_PATH, buffW2); + lstrcatW(buffW2,L"bar"); + ok(CreateDirectoryW(buffW1, NULL), "CreateDirectory(%s) failed\n", wine_dbgstr_w(buffW1)); + ok(CreateDirectoryW(buffW2, NULL), "CreateDirectory(%s) failed\n", wine_dbgstr_w(buffW2)); + lstrcpyW(pathW,buffW2); + lstrcatW(pathW,L"/"); + src = SysAllocString(buffW1); + dst = SysAllocString(pathW); + hr = IFileSystem3_MoveFolder(fs3, src, dst); + ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); + SysFreeString(src); + SysFreeString(dst); + lstrcatW(pathW,L"foo"); + ok(RemoveDirectoryW(pathW), "can't remove %s directory\n", wine_dbgstr_w(pathW)); + ok(RemoveDirectoryW(buffW2), "can't remove %s directory\n", wine_dbgstr_w(buffW2)); }
static void test_DoOpenPipeStream(void)