X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f6fe9f9c0090f8bf3e3d4af89aebb7fbaf2a7a95..0bbe61b8c18a1795189f0cf73cc61c14a0fb846d:/src/common/docview.cpp?ds=sidebyside diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 6c364c1438..d678ca6b54 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -298,8 +298,12 @@ bool wxDocument::SaveAs() #else wxString filter = docTemplate->GetFileFilter() ; #endif + wxString defaultDir = docTemplate->GetDirectory(); + if (defaultDir.IsEmpty()) + defaultDir = wxPathOnly(GetFilename()); + wxString tmp = wxFileSelector(_("Save As"), - docTemplate->GetDirectory(), + defaultDir, wxFileNameFromPath(GetFilename()), docTemplate->GetDefaultExtension(), filter, @@ -2435,15 +2439,22 @@ bool wxTransferStreamToFile(wxInputStream& stream, const wxString& filename) return false; char buf[4096]; - do + for ( ;; ) { stream.Read(buf, WXSIZEOF(buf)); const size_t nRead = stream.LastRead(); - if ( !nRead || !file.Write(buf, nRead) ) + if ( !nRead ) + { + if ( stream.Eof() ) + break; + + return false; + } + + if ( !file.Write(buf, nRead) ) return false; } - while ( !stream.Eof() ); return true; }