Skip to content

Commit c05744a

Browse files
committed
0.8.0.48: Implemented file overwrite confirmation in file picker save mode
1 parent bc8639e commit c05744a

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

src/sqlite-ce-edit/filepicker.c

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,11 +173,18 @@ static void OnItemActivate(void) {
173173
wsprintfW(g_pickerResult, L"%s\\%s", g_pickerDir, item);
174174
}
175175

176-
if (!g_pickerSaveMode) {
177-
/* In open mode, double-click/Enter on file confirms */
178-
g_pickerOK = 1;
179-
PostMessage(g_hwndPicker, WM_CLOSE, 0, 0);
176+
/* In save mode, confirm overwrite */
177+
if (g_pickerSaveMode) {
178+
if (MessageBoxW(g_hwndPicker, L"File exists. Overwrite?",
179+
L"Confirm", MB_YESNO | MB_ICONQUESTION) != IDYES) {
180+
SetFocus(g_hwndList);
181+
return;
182+
}
180183
}
184+
185+
/* File selected - confirm dialog */
186+
g_pickerOK = 1;
187+
PostMessage(g_hwndPicker, WM_CLOSE, 0, 0);
181188
}
182189
}
183190

@@ -294,6 +301,20 @@ static LRESULT CALLBACK PickerWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM
294301
}
295302
}
296303

304+
/* In save mode, confirm overwrite if file exists */
305+
if (g_pickerSaveMode) {
306+
HANDLE hTest = CreateFileW(g_pickerResult, 0, 0, NULL,
307+
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
308+
if (hTest != INVALID_HANDLE_VALUE) {
309+
CloseHandle(hTest);
310+
if (MessageBoxW(hwnd, L"File exists. Overwrite?",
311+
L"Confirm", MB_YESNO | MB_ICONQUESTION) != IDYES) {
312+
SetFocus(g_hwndFilename);
313+
return 0;
314+
}
315+
}
316+
}
317+
297318
g_pickerOK = 1;
298319
}
299320
PostMessage(hwnd, WM_CLOSE, 0, 0);

src/sqlite-ce-edit/globals.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ BOOL WINAPI GetSaveFileNameW(CE_OPENFILENAME*);
8282
** Version
8383
**============================================================================*/
8484

85-
#define SQLITECEDIT_VERSION L"0.8.0.45"
85+
#define SQLITECEDIT_VERSION L"0.8.0.48"
8686

8787
/*============================================================================
8888
** Menu IDs

0 commit comments

Comments
 (0)