@@ -1590,44 +1590,44 @@ void NetPlayClient::onSocketError(QAbstractSocket::SocketError error)
15901590 emit errorOccurred (errorMsg);
15911591}
15921592// -----------------------------------------------------------------------------
1593- int NetPlayClient::requestRomLoad ( const char *romPath )
1593+ int NetPlayClient::requestRomLoad ( const char *romPathIn )
15941594{
15951595 constexpr size_t BufferSize = 32 * 1024 ;
15961596 char buf[BufferSize];
15971597 size_t bytesRead;
15981598 long fileSize = 0 ;
1599+ int userCancel = 0 ;
1600+ const int archiveIndex = -1 ;
1601+ std::string romPath (romPathIn);
15991602 netPlayLoadRomReq msg;
1600- QFileInfo fi ( romPath ) ;
1603+ const char * romextensions[] = { " nes " , " fds " , " nsf " , 0 } ;
16011604
1602- printf (" Prep ROM Load Request: %s \n " , romPath );
1603- FILE * fp = :: fopen ( romPath, " rb" );
1605+ printf (" Prep ROM Load Request: %s \n " , romPath. c_str () );
1606+ FCEUFILE* fp = FCEU_fopen ( romPath. c_str (), nullptr , " rb" , 0 , archiveIndex, romextensions, &userCancel );
16041607
16051608 if (fp == nullptr )
16061609 {
16071610 return -1 ;
16081611 }
1609- fseek ( fp, 0 , SEEK_END);
1610-
1611- fileSize = ftell (fp);
1612-
1613- rewind (fp);
1612+ QFileInfo fi ( fp->filename .c_str () );
1613+ fileSize = fp->size ;
16141614
16151615 msg.hdr .msgSize += fileSize;
16161616 msg.fileSize = fileSize;
16171617 Strlcpy ( msg.fileName , fi.fileName ().toLocal8Bit ().constData (), sizeof (msg.fileName ) );
16181618
1619- printf (" Sending ROM Load Request: %s %lu\n " , romPath , fileSize );
1619+ printf (" Sending ROM Load Request: %s %lu\n " , msg. fileName , fileSize );
16201620
16211621 msg.toNetworkByteOrder ();
16221622 sock->write ( reinterpret_cast <const char *>(&msg), sizeof (netPlayLoadRomReq) );
16231623
1624- while ( (bytesRead = fread ( buf, 1 , sizeof (buf), fp )) > 0 )
1624+ while ( (bytesRead = FCEU_fread ( buf, 1 , sizeof (buf), fp )) > 0 )
16251625 {
16261626 sock->write ( buf, bytesRead );
16271627 }
16281628 sock->flush ();
16291629
1630- ::fclose (fp);
1630+ FCEU_fclose (fp);
16311631
16321632 return 0 ;
16331633}
0 commit comments