X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9298c435cf9b3f5112de555c46c52c51f1d284bb..4a1b95962fd99022e3cb68cf73fe5b29fdfb2adf:/src/common/textfile.cpp diff --git a/src/common/textfile.cpp b/src/common/textfile.cpp index adf3aa659b..5f4dd6a268 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,20 +62,22 @@ bool wxTextFile::OnExists() const bool wxTextFile::OnOpen(const wxString &strBufferName, wxTextBufferOpenMode OpenMode) { - wxFile::OpenMode FileOpenMode = wxFile::read; - - switch (OpenMode) - { + wxFile::OpenMode FileOpenMode; + + switch ( OpenMode ) + { + default: + wxFAIL_MSG( _T("unknown open mode in wxTextFile::Open") ); + // fall through + case ReadAccess : FileOpenMode = wxFile::read; break; + case WriteAccess : FileOpenMode = wxFile::write; break; - default : - wxASSERT(0); // Should not happen. - break; - } + } return m_file.Open(strBufferName.c_str(), FileOpenMode); } @@ -170,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.GetFullPath()); if ( !fileTmp.IsOpened() ) { wxLogError(_("can't write buffer '%s' to disk."), m_strBufferName.c_str());