+ }
+
+ if ( seekable )
+ {
+ // this shouldn't happen but don't overwrite the buffer if it does
+ wxCHECK_MSG( bufPos + nRead <= bufSize, false,
+ _T("read more than file length?") );
+ }
+ else // !seekable
+ {
+ // for non-seekable files we have to allocate more memory on the go
+ if ( !buf.extend(bufPos + nRead - 1 /* it adds 1 internally */) )
+ return false;
+ }
+
+ // append to the buffer
+ memcpy(buf.data() + bufPos, block, nRead);
+ bufPos += nRead;
+ }
+
+ if ( !seekable )
+ {
+ bufSize = bufPos;
+ }
+
+ const wxString str(buf, conv, bufPos);
+
+ // there's no risk of this happening in ANSI build
+#if wxUSE_UNICODE
+ if ( bufSize > 4 && str.empty() )
+ {
+ wxLogError(_("Failed to convert file \"%s\" to Unicode."), GetName());
+ return false;
+ }
+#endif // wxUSE_UNICODE
+
+ free(buf.release()); // we don't need this memory any more