- // 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?") );
+ wxASSERT_MSG( dst - buf.data() == (wxFileOffset)bufSize,
+ wxT("logic error") );
+ }
+ else // file is not seekable
+ {
+ char block[BLOCK_SIZE];
+ for ( ;; )
+ {
+ ssize_t nRead = m_file.Read(block, WXSIZEOF(block));
+
+ if ( nRead == wxInvalidOffset )
+ {
+ // read error (error message already given in wxFile::Read)
+ return false;
+ }
+
+ if ( nRead == 0 )
+ {
+ // if no bytes have been read, presumably this is a
+ // valid-but-empty file
+ if ( bufSize == 0 )
+ return true;
+
+ // otherwise we've finished reading the file
+ break;
+ }