check better before overwriting files (patch 951868)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28465 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
4cc90442d0
commit
90bddb8566
@ -264,6 +264,30 @@ int wxFileDialog::ShowModal()
|
|||||||
of.lpstrFile = fileNameBuffer; // holds returned filename
|
of.lpstrFile = fileNameBuffer; // holds returned filename
|
||||||
of.nMaxFile = wxMAXPATH;
|
of.nMaxFile = wxMAXPATH;
|
||||||
|
|
||||||
|
// we must set the default extension because otherwise Windows would check
|
||||||
|
// for the existing of a wrong file with wxOVERWRITE_PROMPT (i.e. if the
|
||||||
|
// user types "foo" and the default extension is ".bar" we should force it
|
||||||
|
// to check for "foo.bar" existence and not "foo")
|
||||||
|
wxString defextBuffer; // we need it to be alive until GetSaveFileName()!
|
||||||
|
if (m_dialogStyle & wxSAVE)
|
||||||
|
{
|
||||||
|
const wxChar* extension = filterBuffer;
|
||||||
|
int maxFilter = (int)(of.nFilterIndex*2L) - 1;
|
||||||
|
|
||||||
|
for( int i = 0; i < maxFilter; i++ ) // get extension
|
||||||
|
extension = extension + wxStrlen( extension ) + 1;
|
||||||
|
|
||||||
|
// use dummy name a to avoid assert in AppendExtension
|
||||||
|
defextBuffer = AppendExtension(wxT("a"), extension);
|
||||||
|
if (defextBuffer.StartsWith(wxT("a.")))
|
||||||
|
{
|
||||||
|
defextBuffer.Mid(2);
|
||||||
|
of.lpstrDefExt = defextBuffer.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//== Execute FileDialog >>=================================================
|
||||||
|
|
||||||
//== Execute FileDialog >>=================================================
|
//== Execute FileDialog >>=================================================
|
||||||
|
|
||||||
bool success = (m_dialogStyle & wxSAVE ? GetSaveFileName(&of)
|
bool success = (m_dialogStyle & wxSAVE ? GetSaveFileName(&of)
|
||||||
|
Loading…
Reference in New Issue
Block a user