]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/textfile.cpp
removed wxYield from wxHtmlWindow (seems to work w/o it and yielding caused reentranc...
[wxWidgets.git] / src / common / textfile.cpp
index adf3aa659be0f1a7834a94e23694720296c1c088..5f4dd6a2687ecfb3b641190e18ecf415847af994 100644 (file)
 #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());