summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2013-06-04 18:07:59 +0000
committerGerald Combs <gerald@wireshark.org>2013-06-04 18:07:59 +0000
commit8b4b8154a49f38ff60460d8f698d419d2ce8ae33 (patch)
treea76f57c4d384d354b477e0dbe0f62994803aff5c
parentfd5c1ddf5c7a01066f2c73e3f1148c87bb747695 (diff)
downloadwireshark-8b4b8154a49f38ff60460d8f698d419d2ce8ae33.tar.gz
The CommDlg_OpenSave_GetFilePath macro fetches the path+name of the most
recently selected file in the current file dialog. This isn't the proper routine to use when trying to figure out the save/export file name. We have to dig through the OPENFILENAME struct instead. Fixes bug 8224. #Backport 1.10 svn path=/trunk/; revision=49765
-rw-r--r--ui/win32/file_dlg_win32.c62
1 files changed, 26 insertions, 36 deletions
diff --git a/ui/win32/file_dlg_win32.c b/ui/win32/file_dlg_win32.c
index 08e718c0fa..0d2007cf6d 100644
--- a/ui/win32/file_dlg_win32.c
+++ b/ui/win32/file_dlg_win32.c
@@ -1658,9 +1658,7 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
break;
case CDN_FILEOK: {
HWND parent;
- TCHAR file_name16_selected[MAX_PATH];
- char *file_name8_selected;
- int selected_size;
+ char *file_name8;
/* Fetch our compression value */
cur_ctrl = GetDlgItem(sf_hwnd, EWFD_GZIP_CB);
@@ -1669,22 +1667,19 @@ save_as_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param, LPARAM l_param) {
else
g_compressed = FALSE;
- /* Check if trying to do 'save as' to the currently open file */
+ /* Check if we're trying to overwrite the currently open file */
parent = GetParent(sf_hwnd);
- selected_size = CommDlg_OpenSave_GetFilePath(parent, file_name16_selected, MAX_PATH);
- if (selected_size > 0) {
- file_name8_selected = utf_16to8(file_name16_selected);
- if (files_identical(cfile.filename, file_name8_selected)) {
- /* XXX: Is MessageBox the best way to pop up an error ? How to make text bold ? */
- gchar *str = g_strdup_printf(
- "Capture File \"%s\" identical to loaded file !!\n\n"
- "Please choose a different filename.",
- file_name8_selected);
- MessageBox( parent, utf_8to16(str), _T("Error"), MB_ICONERROR | MB_APPLMODAL | MB_OK);
- g_free(str);
- SetWindowLongPtr(sf_hwnd, DWLP_MSGRESULT, 1L); /* Don't allow ! */
- return 1;
- }
+ file_name8 = utf_16to8(notify->lpOFN->lpstrFile);
+ if (files_identical(cfile.filename, file_name8)) {
+ /* XXX: Is MessageBox the best way to pop up an error ? How to make text bold ? */
+ gchar *str = g_strdup_printf(
+ "Capture File \"%s\" identical to loaded file.\n\n"
+ "Please choose a different filename.",
+ file_name8);
+ MessageBox( parent, utf_8to16(str), _T("Error"), MB_ICONERROR | MB_APPLMODAL | MB_OK);
+ g_free(str);
+ SetWindowLongPtr(sf_hwnd, DWLP_MSGRESULT, 1L); /* Don't allow ! */
+ return 1;
}
}
break;
@@ -1763,9 +1758,7 @@ export_specified_packets_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param,
break;
case CDN_FILEOK: {
HWND parent;
- TCHAR file_name16_selected[MAX_PATH];
- char *file_name8_selected;
- int selected_size;
+ char *file_name8;
/* Fetch our compression value */
cur_ctrl = GetDlgItem(sf_hwnd, EWFD_GZIP_CB);
@@ -1774,22 +1767,19 @@ export_specified_packets_file_hook_proc(HWND sf_hwnd, UINT msg, WPARAM w_param,
else
g_compressed = FALSE;
- /* Check if trying to do 'save as' to the currently open file */
+ /* Check if we're trying to overwrite the currently open file */
parent = GetParent(sf_hwnd);
- selected_size = CommDlg_OpenSave_GetFilePath(parent, file_name16_selected, MAX_PATH);
- if (selected_size > 0) {
- file_name8_selected = utf_16to8(file_name16_selected);
- if (files_identical(cfile.filename, file_name8_selected)) {
- /* XXX: Is MessageBox the best way to pop up an error ? How to make text bold ? */
- gchar *str = g_strdup_printf(
- "Capture File \"%s\" identical to loaded file.\n\n"
- "Please choose a different filename.",
- file_name8_selected);
- MessageBox( parent, utf_8to16(str), _T("Error"), MB_ICONERROR | MB_APPLMODAL | MB_OK);
- g_free(str);
- SetWindowLongPtr(sf_hwnd, DWLP_MSGRESULT, 1L); /* Don't allow ! */
- return 1;
- }
+ file_name8 = utf_16to8(notify->lpOFN->lpstrFile);
+ if (files_identical(cfile.filename, file_name8)) {
+ /* XXX: Is MessageBox the best way to pop up an error ? How to make text bold ? */
+ gchar *str = g_strdup_printf(
+ "Capture File \"%s\" identical to loaded file.\n\n"
+ "Please choose a different filename.",
+ file_name8);
+ MessageBox( parent, utf_8to16(str), _T("Error"), MB_ICONERROR | MB_APPLMODAL | MB_OK);
+ g_free(str);
+ SetWindowLongPtr(sf_hwnd, DWLP_MSGRESULT, 1L); /* Don't allow ! */
+ return 1;
}
}
break;