]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/docview.cpp
Some C++Builder fixes
[wxWidgets.git] / src / common / docview.cpp
index 8f693926e5429ec3a85d7cd34a1b01a5f0a5a817..538bb871f45898b5e2cbc1cf8441cb6a75166dca 100644 (file)
@@ -806,7 +806,10 @@ void wxDocManager::OnFileNew(wxCommandEvent& WXUNUSED(event))
 
 void wxDocManager::OnFileOpen(wxCommandEvent& WXUNUSED(event))
 {
-    CreateDocument(wxString(""), 0);
+    if ( !CreateDocument(wxString(""), 0) )
+    {
+        OnOpenFileFailure();
+    }
 }
 
 void wxDocManager::OnFileRevert(wxCommandEvent& WXUNUSED(event))
@@ -2191,6 +2194,42 @@ bool wxTransferStreamToFile(istream& stream, const wxString& filename)
     fclose (fd1);
     return TRUE;
 }
+#else
+bool wxTransferFileToStream(const wxString& filename, wxOutputStream& stream)
+{
+    FILE *fd1;
+    int ch;
+
+    if ((fd1 = fopen (filename.fn_str(), "rb")) == NULL)
+        return FALSE;
+
+    while ((ch = getc (fd1)) != EOF)
+        stream.PutC((char) ch);
+
+    fclose (fd1);
+    return TRUE;
+}
+
+bool wxTransferStreamToFile(wxInputStream& stream, const wxString& filename)
+{
+    FILE *fd1;
+    char ch;
+
+    if ((fd1 = fopen (filename.fn_str(), "wb")) == NULL)
+    {
+        return FALSE;
+    }
+
+    int len = stream.StreamSize();
+    // TODO: is this the correct test for EOF?
+    while (stream.TellI() < (len - 1))
+    {
+        ch = stream.GetC();
+        putc (ch, fd1);
+    }
+    fclose (fd1);
+    return TRUE;
+}
 #endif
 
 #endif // wxUSE_DOC_VIEW_ARCHITECTURE