]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/file.cpp
No changes, just remove some unneeded variables initializations.
[wxWidgets.git] / src / common / file.cpp
index 2701cfcb41b9bf70150fe4f30abbd5239469c3ad..02a15cb2ca492cdc1eea6882b070c05db644d315 100644 (file)
@@ -291,6 +291,34 @@ bool wxFile::Close()
 // read/write
 // ----------------------------------------------------------------------------
 
+bool wxFile::ReadAll(wxString *str, const wxMBConv& conv)
+{
+    wxCHECK_MSG( str, false, wxS("Output string must be non-NULL") );
+
+    size_t length = wx_truncate_cast(size_t, Length());
+    wxCHECK_MSG( (wxFileOffset)length == Length(), false, wxT("huge file not supported") );
+
+    wxCharBuffer buf(length);
+    char* p = buf.data();
+    for ( ;; )
+    {
+        static const unsigned READSIZE = 4096;
+
+        ssize_t read = Read(p, length > READSIZE ? READSIZE : length);
+        if ( read == wxInvalidOffset )
+            return false;
+
+        p += read;
+    }
+
+    *p = 0;
+
+    wxString strTmp(buf, conv);
+    str->swap(strTmp);
+
+    return true;
+}
+
 // read
 ssize_t wxFile::Read(void *pBuf, size_t nCount)
 {
@@ -460,7 +488,7 @@ bool wxFile::Eof() const
 
     wxFileOffset iRc;
 
-#if defined(__DOS__) || defined(__UNIX__) || defined(__GNUWIN32__) || defined( __MWERKS__ )
+#if defined(__DOS__) || defined(__UNIX__) || defined(__GNUWIN32__)
     // @@ this doesn't work, of course, on unseekable file descriptors
     wxFileOffset ofsCur = Tell(),
     ofsMax = Length();