Commit 33ee219c authored by Mikołaj Zalewski's avatar Mikołaj Zalewski Committed by Alexandre Julliard

shell32: Allow overwriting files in SHFileOperation(FO_COPY) (with confirmation dialogs).

parent c55277c7
......@@ -165,8 +165,12 @@ STRINGTABLE DISCARDABLE
IDS_DELETEITEM_TEXT " '%1'?"
IDS_DELETEMULTIPLE_TEXT " %1 ?"
IDS_DELETESELECTED_TEXT " ?"
IDS_OVERWRITEFILE_TEXT " %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION " "
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE ""
......
......@@ -163,10 +163,14 @@ STRINGTABLE DISCARDABLE
IDS_CREATEFOLDER_CAPTION "Chyba pi pokusu vytvoit nov adres"
IDS_DELETEITEM_CAPTION "Potvrdit odstrann souboru"
IDS_DELETEFOLDER_CAPTION "Potvrdit odstrann adrese"
IDS_OVERWRITEFILE_CAPTION "Potvrdit pepsn souboru"
IDS_DELETEITEM_TEXT "Opravdu chcete odstranit '%1'?"
IDS_DELETEMULTIPLE_TEXT "Opravdu chcete odstranit tchto %1 poloek?"
IDS_OVERWRITEFILE_TEXT "Pejete si pepsat soubor '%1'?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Potvrdit pepsn souboru"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
}
/* columns in the shellview */
......
......@@ -173,8 +173,12 @@ STRINGTABLE DISCARDABLE
IDS_TRASHFOLDER_TEXT "Sind Sie sich sicher, dass Sie '%1' und seinen Inhalt in den Mll verschieben mchten?"
IDS_TRASHMULTIPLE_TEXT "Sind Sie sich sicher, dass Sie diese %1 Dateien in den Mll verschieben mchten?"
IDS_CANTTRASH_TEXT "Das Objekt '%1' kann nicht in den Mll verschoben werden. Mchten Sie es stattdessen lschen?"
IDS_OVERWRITEFILE_TEXT "Mchten Sie, dass die Datei '%1' berschrieben wird ?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Besttigung: Datei berschreiben"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "Neustarten"
......
......@@ -185,8 +185,12 @@ STRINGTABLE DISCARDABLE
IDS_TRASHFOLDER_TEXT "Are you sure that you want to send '%1' and all it's content to the Trash?"
IDS_TRASHMULTIPLE_TEXT "Are you sure that you want to send these %1 items to the Trash?"
IDS_CANTTRASH_TEXT "The item '%1' can't be sent to Trash. Do you want to delete it instead?"
IDS_OVERWRITEFILE_TEXT "OverWrite File %1?"
IDS_OVERWRITEFILE_CAPTION "Confirm File OverWrite"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Confirm file overwrite"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "Restart"
......
......@@ -163,8 +163,12 @@ STRINGTABLE DISCARDABLE
IDS_DELETEFOLDER_CAPTION "Konfirmu forigon de dosierujo"
IDS_DELETEITEM_TEXT "u vi estas certa pri forigo de '%1'?"
IDS_DELETEMULTIPLE_TEXT "u vi estas certa pri forigo de i tiuj %1 komponantoj?"
IDS_OVERWRITEFILE_TEXT "u vi supreskribas la dosieron %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Konfirmu supreskribiton de dosieron"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
}
/* columns in the shellview */
......@@ -222,4 +226,3 @@ STRINGTABLE DISCARDABLE
IDS_COMMON_VIDEO "Documents\\Video"
IDS_CDBURN_AREA "Local Settings\\Application Data\\Microsoft\\CD Burning"
}
......@@ -162,8 +162,12 @@ STRINGTABLE DISCARDABLE
IDS_DELETEFOLDER_CAPTION "Confirmar eliminacin de carpeta"
IDS_DELETEITEM_TEXT "Seguro que desea eliminar '%1'?"
IDS_DELETEMULTIPLE_TEXT "Seguro que desea eliminar estos %1 elementos?"
IDS_OVERWRITEFILE_TEXT "Sobreescribir el archivo '%1'?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Confirmar sobreescritura de archivo"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
}
/* columns in the shellview */
......
......@@ -164,8 +164,12 @@ STRINGTABLE DISCARDABLE
IDS_DELETEFOLDER_CAPTION "Vahvista kansion tuhoaminen"
IDS_DELETEITEM_TEXT "Haluatko varmasti tuhota '%1':n?"
IDS_DELETEMULTIPLE_TEXT "Haluatko varmasti tuhota nm %1?"
IDS_OVERWRITEFILE_TEXT "Ylikirjoita tiedosto %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Vahvista tiedoston ylikirjoitus"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "Kynnist uudelleen"
......
......@@ -176,8 +176,12 @@ STRINGTABLE DISCARDABLE
IDS_TRASHFOLDER_TEXT "tes-vous sr de vouloir mettre %1 et tout ce qu'il contient dans la corbeille?"
IDS_TRASHMULTIPLE_TEXT "tes-vous sr de vouloir mettre ces %1 lments dans la corbeille?"
IDS_CANTTRASH_TEXT "L'lment %1 ne peut pas tre mis dans la corbeille. Souhaitez-vous le supprimer la place?"
IDS_OVERWRITEFILE_TEXT "craser le fichier %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Confirmer l'crasement du fichier"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "Redmarrer"
......
......@@ -164,8 +164,12 @@ STRINGTABLE DISCARDABLE
IDS_DELETEFOLDER_CAPTION "Confermare la cancellazione della cartella"
IDS_DELETEITEM_TEXT "Sei sicuro di voler cancellare '%1'?"
IDS_DELETEMULTIPLE_TEXT "Sei sicuro di voler cancellare questi %1 elementi?"
IDS_OVERWRITEFILE_TEXT "Sovrascrivere il File %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Confermare la sovrascrizione del File"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "Riavvia"
......
......@@ -173,8 +173,12 @@ IDS_TRASHITEM_TEXT "당신은 '%1' 을(를) 휴지통으로 보내기를 바랍니까?"
IDS_TRASHFOLDER_TEXT "당신은 '%1' 과 그 안의 내용을 휴지통으로 보내기를 바랍니까?"
IDS_TRASHMULTIPLE_TEXT "당신은 '%1' 들을(를) 휴지통으로 보내기를 바랍니까?"
IDS_CANTTRASH_TEXT "The item '%1' can't be sent to Trash. Do you want to delete it instead?"
IDS_OVERWRITEFILE_TEXT "파일 %1을 덮어쓰겠습니까?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "파일 덮어쓰기 확인"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "다시 시작"
......
......@@ -172,8 +172,12 @@ STRINGTABLE DISCARDABLE
IDS_TRASHFOLDER_TEXT "Virkelig legge %1 og alt innholdet i papirkurven?"
IDS_TRASHMULTIPLE_TEXT "Virkelig legge disse %1 valgte elementene i papirkurven?"
IDS_CANTTRASH_TEXT "Elementet %1 kan ikke legges i papirkurven. Vil du slette det i stedet?"
IDS_OVERWRITEFILE_TEXT "Overskrive filen %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Bekreft overskriving av fil"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "Starte p nytt"
......
......@@ -173,8 +173,12 @@ STRINGTABLE DISCARDABLE
IDS_TRASHFOLDER_TEXT "Czy jeste pewien, e chcesz umieci folder '%1' i ca jego zawarto w koszu"
IDS_TRASHMULTIPLE_TEXT "Elementw: %1 - czy na pewno chcesz je umieci w Koszu?"
IDS_CANTTRASH_TEXT "Nie mog przenie elementu '%1' do Kosza. Czy chcesz go zamiast tego usun?"
IDS_OVERWRITEFILE_TEXT "Zastpi plik %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Potwierd zastpienie pliku"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "Uruchom ponownie"
......
......@@ -256,8 +256,12 @@ STRINGTABLE DISCARDABLE
IDS_DELETEFOLDER_CAPTION "Confirmar excluso de pasta"
IDS_DELETEITEM_TEXT "Voc tem certeza que deseja excluir '%1'?"
IDS_DELETEMULTIPLE_TEXT "Voc tem certeza que deseja excluir estes %1 itens?"
IDS_OVERWRITEFILE_TEXT "Sobreescrever arquivo %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Confirmar sobreescrever arquivo"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "Reiniciar"
......
......@@ -165,8 +165,12 @@ STRINGTABLE DISCARDABLE
IDS_DELETEFOLDER_CAPTION " "
IDS_DELETEITEM_TEXT " '%1'?"
IDS_DELETEMULTIPLE_TEXT " (%1?"
IDS_OVERWRITEFILE_TEXT " () %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION " "
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE ""
......
......@@ -172,8 +172,12 @@ STRINGTABLE DISCARDABLE
IDS_TRASHFOLDER_TEXT "'%1' adl eyi ve tm ieriini pe gndermek istediinizden emin misiniz?"
IDS_TRASHMULTIPLE_TEXT "Bu %1 eyi pe gndermek istediinizden emin misiniz?"
IDS_CANTTRASH_TEXT "'%1' adl e pe gnderilemiyor. Tamamen silmek ister misiniz?"
IDS_OVERWRITEFILE_TEXT "%1 dosyasnn zerine yazmak istiyor musunuz?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "Dosya zerine Yazmay Onayla"
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
/* message box strings */
IDS_RESTART_TITLE "Yeniden Balat"
......
......@@ -161,8 +161,12 @@ STRINGTABLE DISCARDABLE
IDS_DELETEFOLDER_CAPTION "ϳ "
IDS_DELETEITEM_TEXT " , '%1'?"
IDS_DELETEMULTIPLE_TEXT " , %1 ()?"
IDS_OVERWRITEFILE_TEXT " %1?"
IDS_OVERWRITEFILE_TEXT "This folder already contains a file called '%1'.\n\nDo you want to replace it?"
IDS_OVERWRITEFILE_CAPTION "ϳ "
IDS_OVERWRITEFOLDER_TEXT "This folder already contains a folder named '%1'.\n\n"\
"If the files in the destination folder have the same names as files in the\n"\
"selected folder they will be replaced. Do you still want to move or copy\n"\
"the folder?"
}
/* columns in the shellview */
......
......@@ -153,9 +153,10 @@ void FreeChangeNotifications(void);
#define ASK_TRASH_FOLDER 8
#define ASK_TRASH_MULTIPLE_ITEM 9
#define ASK_CANT_TRASH_ITEM 10
#define ASK_OVERWRITE_FOLDER 11
BOOL SHELL_DeleteDirectoryW(HWND hwnd, LPCWSTR pwszDir, BOOL bShowUI);
BOOL SHELL_ConfirmDialogW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir);
BOOL SHELL_ConfirmYesNoW(HWND hWnd, int nKindOfDialog, LPCWSTR szDir);
/* 16-bit functions */
void WINAPI DragAcceptFiles16(HWND16 hWnd, BOOL16 b);
......
......@@ -1829,7 +1829,7 @@ static HRESULT UNIXFS_delete_with_syscalls(UnixFolder *This, UINT cidl, LPCITEMI
static const WCHAR empty[] = {0};
int i;
if (!SHELL_ConfirmDialogW(GetActiveWindow(), ASK_DELETE_SELECTED, empty))
if (!SHELL_ConfirmYesNoW(GetActiveWindow(), ASK_DELETE_SELECTED, empty))
return S_OK;
lstrcpyA(szAbsolute, This->m_pszPath);
......
......@@ -92,6 +92,7 @@
#define IDS_TRASHITEM_TEXT 138
#define IDS_TRASHMULTIPLE_TEXT 139
#define IDS_CANTTRASH_TEXT 140
#define IDS_OVERWRITEFOLDER_TEXT 141
/* Note: this string is referenced from the registry*/
#define IDS_RECYCLEBIN_FOLDER_NAME 8964
......
......@@ -63,6 +63,21 @@ static BOOL file_exists(const CHAR *name)
return GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES;
}
static BOOL file_has_content(const CHAR *name, const CHAR *content)
{
CHAR buf[MAX_PATH];
HANDLE file;
DWORD read;
file = CreateFileA(name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
if (file == INVALID_HANDLE_VALUE)
return FALSE;
ReadFile(file, buf, MAX_PATH - 1, &read, NULL);
buf[read] = 0;
CloseHandle(file);
return strcmp(buf, content)==0;
}
/* initializes the tests */
static void init_shfo_tests(void)
{
......@@ -92,6 +107,7 @@ static void clean_after_shfo_tests(void)
DeleteFileA("test2.txt");
DeleteFileA("test3.txt");
DeleteFileA("test_5.txt");
DeleteFileA("one.txt");
DeleteFileA("test4.txt\\test1.txt");
DeleteFileA("test4.txt\\test2.txt");
DeleteFileA("test4.txt\\test3.txt");
......@@ -761,6 +777,45 @@ static void test_copy(void)
ok(retval == 1026, "Expected 1026, got %d\n", retval);
ok(!file_exists("nonexistent\\e.txt"), "Expected nonexistent\\e.txt to not exist\n");
ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n");
/* Overwrite tests */
clean_after_shfo_tests();
init_shfo_tests();
shfo.fFlags = FOF_NOCONFIRMATION;
shfo.pFrom = "test1.txt\0";
shfo.pTo = "test2.txt\0";
shfo.fAnyOperationsAborted = FALSE;
/* without FOF_NOCOFIRMATION the confirmation is Yes/No */
retval = SHFileOperation(&shfo);
ok(retval == 0, "Expected 0, got %d\n", retval);
ok(file_has_content("test2.txt", "test1.txt\n"), "The file was not copied\n");
shfo.pFrom = "test3.txt\0test1.txt\0";
shfo.pTo = "test2.txt\0one.txt\0";
shfo.fFlags = FOF_NOCONFIRMATION | FOF_MULTIDESTFILES;
/* without FOF_NOCOFIRMATION the confirmation is Yes/Yes to All/No/Cancel */
retval = SHFileOperation(&shfo);
ok(retval == 0, "Expected 0, got %d\n", retval);
ok(file_has_content("test2.txt", "test3.txt\n"), "The file was not copied\n");
shfo.pFrom = "one.txt\0";
shfo.pTo = "testdir2\0";
shfo.fFlags = FOF_NOCONFIRMATION;
/* without FOF_NOCOFIRMATION the confirmation is Yes/No */
retval = SHFileOperation(&shfo);
ok(retval == 0, "Expected 0, got %d\n", retval);
ok(file_has_content("testdir2\\one.txt", "test1.txt\n"), "The file was not copied\n");
createTestFile("test4.txt\\test1.txt");
shfo.pFrom = "test4.txt\0";
shfo.pTo = "testdir2\0";
shfo.fFlags = FOF_NOCONFIRMATION;
ok(!SHFileOperation(&shfo), "First SHFileOperation failed\n");
createTestFile("test4.txt\\.\\test1.txt"); /* modify the content of the file */
/* without FOF_NOCOFIRMATION the confirmation is "This folder already contains a folder named ..." */
retval = SHFileOperation(&shfo);
ok(retval == 0, "Expected 0, got %d\n", retval);
ok(file_has_content("testdir2\\test4.txt\\test1.txt", "test4.txt\\.\\test1.txt\n"), "The file was not copied\n");
}
/* tests the FO_MOVE action */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment