X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/27752aab2a347fe56975291ef933874c7e3c308b..a9249b2eb2a40d8c71f828669045c4ddaa8dc5ff:/src/common/textfile.cpp diff --git a/src/common/textfile.cpp b/src/common/textfile.cpp index 77510ace07..26053922cd 100644 --- a/src/common/textfile.cpp +++ b/src/common/textfile.cpp @@ -31,13 +31,14 @@ #if wxUSE_TEXTFILE #ifndef WX_PRECOMP - #include "wx/string.h" - #include "wx/intl.h" - #include "wx/file.h" - #include "wx/log.h" + #include "wx/string.h" + #include "wx/intl.h" + #include "wx/file.h" + #include "wx/log.h" #endif #include "wx/textfile.h" +#include "wx/filename.h" // ============================================================================ // wxTextFile class implementation @@ -61,21 +62,22 @@ bool wxTextFile::OnExists() const bool wxTextFile::OnOpen(const wxString &strBufferName, wxTextBufferOpenMode OpenMode) { - wxFile::OpenMode FileOpenMode = wxFile::read; - int nAssertVal = 0; + wxFile::OpenMode FileOpenMode; + + switch ( OpenMode ) + { + default: + wxFAIL_MSG( _T("unknown open mode in wxTextFile::Open") ); + // fall through - switch (OpenMode) - { case ReadAccess : FileOpenMode = wxFile::read; break; + case WriteAccess : FileOpenMode = wxFile::write; break; - default : - wxASSERT(nAssertVal); // Should not happen. - break; - } + } return m_file.Open(strBufferName.c_str(), FileOpenMode); } @@ -171,7 +173,11 @@ bool wxTextFile::OnRead(wxMBConv& conv) bool wxTextFile::OnWrite(wxTextFileType typeNew, wxMBConv& conv) { - wxTempFile fileTmp(m_strBufferName); + wxFileName fn = m_strBufferName; + if ( !fn.IsAbsolute() ) + fn.Normalize(); + + wxTempFile fileTmp(fn.GetFullName()); if ( !fileTmp.IsOpened() ) { wxLogError(_("can't write buffer '%s' to disk."), m_strBufferName.c_str());