Skip to content

Commit c06632e

Browse files
committed
replace remaining uses of fopen with Platform::OpenFile
should prevent code page issues on windows
1 parent 5c45016 commit c06632e

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

src/frontend/qt_sdl/TitleManagerDialog.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,10 @@ TitleImportDialog::~TitleImportDialog()
412412

413413
void TitleImportDialog::accept()
414414
{
415-
QString path;
416-
FILE* f;
417-
418415
bool tmdfromfile = (grpTmdSource->checkedId() == 0);
419416

420-
path = ui->txtAppFile->text();
421-
f = fopen(path.toStdString().c_str(), "rb");
417+
QString path = ui->txtAppFile->text();
418+
Platform::FileHandle* f = Platform::OpenFile(path.toStdString(), FileMode::Read);
422419
if (!f)
423420
{
424421
QMessageBox::critical(this,
@@ -427,9 +424,9 @@ void TitleImportDialog::accept()
427424
return;
428425
}
429426

430-
fseek(f, 0x230, SEEK_SET);
431-
fread(titleid, 8, 1, f);
432-
fclose(f);
427+
Platform::FileSeek(f, 0x230, FileSeekOrigin::Start);
428+
Platform::FileRead(titleid, 8, 1, f);
429+
Platform::CloseFile(f);
433430

434431
if (titleid[1] != 0x00030004)
435432
{
@@ -442,7 +439,7 @@ void TitleImportDialog::accept()
442439
if (tmdfromfile)
443440
{
444441
path = ui->txtTmdFile->text();
445-
f = fopen(path.toStdString().c_str(), "rb");
442+
Platform::FileHandle* f = Platform::OpenFile(path.toStdString(), FileMode::Read);
446443
if (!f)
447444
{
448445
QMessageBox::critical(this,
@@ -451,8 +448,8 @@ void TitleImportDialog::accept()
451448
return;
452449
}
453450

454-
fread((void *) tmdData, sizeof(DSi_TMD::TitleMetadata), 1, f);
455-
fclose(f);
451+
Platform::FileRead((void *) tmdData, sizeof(DSi_TMD::TitleMetadata), 1, f);
452+
Platform::CloseFile(f);
456453

457454
u32 tmdtitleid[2];
458455
tmdtitleid[0] = tmdData->GetCategory();

0 commit comments

Comments
 (0)