+
+        // if the file is seekable, also check that we're at its beginning
+        wxASSERT_MSG( m_file.Tell() == 0, _T("should be at start of file") );
+
+        char *dst = buf.data();
+        for ( size_t nRemaining = bufSize; nRemaining > 0; )
+        {
+            size_t nToRead = BLOCK_SIZE;
+
+            // the file size could have changed, avoid overflowing the buffer
+            // even if it did
+            if ( nToRead > nRemaining )
+                nToRead = nRemaining;
+
+            ssize_t nRead = m_file.Read(dst, nToRead);
+
+            if ( nRead == wxInvalidOffset )
+            {
+                // read error (error message already given in wxFile::Read)
+                return false;
+            }
+
+            if ( nRead == 0 )
+            {
+                // this file can't be empty because we checked for this above
+                // so this must be the end of file
+                break;
+            }
+
+            dst += nRead;
+            nRemaining -= nRead;