+ wxCharBuffer buf;
+
+ // first determine if the file is seekable or not and so whether we can
+ // determine its length in advance
+ wxFileOffset fileLength;
+ {
+ wxLogNull logNull;
+ fileLength = m_file.Length();
+ }
+
+ // some non-seekable files under /proc under Linux pretend that they're
+ // seekable but always return 0; others do return an error
+ const bool seekable = fileLength != wxInvalidOffset && fileLength != 0;
+ if ( seekable )
+ {
+ // we know the required length, so set the buffer size in advance
+ bufSize = fileLength;
+ if ( !buf.extend(bufSize - 1 /* it adds 1 internally */) )
+ return false;
+
+ // 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") );
+ }
+
+ for ( ;; )