#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
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);
}
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());