@@ -112,11 +112,11 @@ bool LoadFromFile(DataArray* data, const char* filename)
112
112
const size_t num_read = stream->Read (data->data (), DATA_SIZE);
113
113
if (num_read != DATA_SIZE)
114
114
{
115
- Log_ErrorPrintf (" Only read %zu of %u sectors from '%s '" , num_read / FRAME_SIZE, NUM_FRAMES, filename);
115
+ Log_ErrorFmt (" Only read {} of {} sectors from '{} '" , num_read / FRAME_SIZE, static_cast < u32 >( NUM_FRAMES) , filename);
116
116
return false ;
117
117
}
118
118
119
- Log_InfoPrintf (" Loaded memory card from %s " , filename);
119
+ Log_VerboseFmt (" Loaded memory card from {} " , filename);
120
120
return true ;
121
121
}
122
122
@@ -127,18 +127,18 @@ bool SaveToFile(const DataArray& data, const char* filename)
127
127
BYTESTREAM_OPEN_ATOMIC_UPDATE | BYTESTREAM_OPEN_STREAMED);
128
128
if (!stream)
129
129
{
130
- Log_ErrorPrintf (" Failed to open '%s ' for writing." , filename);
130
+ Log_ErrorFmt (" Failed to open '{} ' for writing." , filename);
131
131
return false ;
132
132
}
133
133
134
134
if (!stream->Write2 (data.data (), DATA_SIZE) || !stream->Commit ())
135
135
{
136
- Log_ErrorPrintf (" Failed to write sectors to '%s '" , filename);
136
+ Log_ErrorFmt (" Failed to write sectors to '{} '" , filename);
137
137
stream->Discard ();
138
138
return false ;
139
139
}
140
140
141
- Log_InfoPrintf (" Saved memory card to '%s '" , filename);
141
+ Log_VerboseFmt (" Saved memory card to '{} '" , filename);
142
142
return true ;
143
143
}
144
144
@@ -266,7 +266,7 @@ std::vector<FileInfo> EnumerateFiles(const DataArray& data, bool include_deleted
266
266
if (fi.num_blocks == FRAMES_PER_BLOCK)
267
267
{
268
268
// invalid
269
- Log_WarningPrintf (" Invalid block chain in block %u " , dir_frame);
269
+ Log_WarningFmt (" Invalid block chain in block {} " , dir_frame);
270
270
continue ;
271
271
}
272
272
@@ -280,7 +280,7 @@ std::vector<FileInfo> EnumerateFiles(const DataArray& data, bool include_deleted
280
280
num_icon_frames = 3 ;
281
281
else
282
282
{
283
- Log_WarningPrintf (" Unknown icon flag 0x% 02X" , tf->icon_flag );
283
+ Log_WarningFmt (" Unknown icon flag 0x{: 02X} " , tf->icon_flag );
284
284
continue ;
285
285
}
286
286
@@ -332,14 +332,14 @@ bool WriteFile(DataArray* data, const std::string_view& filename, const std::vec
332
332
{
333
333
if (buffer.empty ())
334
334
{
335
- Log_ErrorPrintf (" Failed to write file to memory card: buffer is empty" );
335
+ Log_ErrorPrint (" Failed to write file to memory card: buffer is empty" );
336
336
return false ;
337
337
}
338
338
339
339
const u32 num_blocks = (static_cast <u32 >(buffer.size ()) + (BLOCK_SIZE - 1 )) / BLOCK_SIZE;
340
340
if (GetFreeBlockCount (*data) < num_blocks)
341
341
{
342
- Log_ErrorPrintf (" Failed to write file to memory card: insufficient free blocks" );
342
+ Log_ErrorPrint (" Failed to write file to memory card: insufficient free blocks" );
343
343
return false ;
344
344
}
345
345
@@ -382,13 +382,13 @@ bool WriteFile(DataArray* data, const std::string_view& filename, const std::vec
382
382
std::memset (data_block + size_to_copy, 0 , size_to_zero);
383
383
}
384
384
385
- Log_InfoPrintf (" Wrote %zu byte (%u block) file to memory card" , buffer.size (), num_blocks);
385
+ Log_InfoFmt (" Wrote {} byte ({} block) file to memory card" , buffer.size (), num_blocks);
386
386
return true ;
387
387
}
388
388
389
389
bool DeleteFile (DataArray* data, const FileInfo& fi, bool clear_sectors)
390
390
{
391
- Log_InfoPrintf (" Deleting '%s ' from memory card (%u blocks)" , fi.filename . c_str () , fi.num_blocks );
391
+ Log_InfoFmt (" Deleting '{} ' from memory card ({} blocks)" , fi.filename , fi.num_blocks );
392
392
393
393
u32 block_number = fi.first_block ;
394
394
for (u32 i = 0 ; i < fi.num_blocks && (block_number > 0 && block_number < NUM_BLOCKS); i++)
@@ -421,11 +421,11 @@ bool UndeleteFile(DataArray* data, const FileInfo& fi)
421
421
{
422
422
if (!fi.deleted )
423
423
{
424
- Log_ErrorPrintf (" File '%s ' is not deleted" , fi.filename . c_str () );
424
+ Log_ErrorFmt (" File '{} ' is not deleted" , fi.filename );
425
425
return false ;
426
426
}
427
427
428
- Log_InfoPrintf (" Undeleting '%s ' from memory card (%u blocks)" , fi.filename . c_str () , fi.num_blocks );
428
+ Log_InfoFmt (" Undeleting '{} ' from memory card ({} blocks)" , fi.filename , fi.num_blocks );
429
429
430
430
// check that all blocks are present first
431
431
u32 block_number = fi.first_block ;
@@ -439,26 +439,26 @@ bool UndeleteFile(DataArray* data, const FileInfo& fi)
439
439
{
440
440
if (df->block_allocation_state != 0xA1 )
441
441
{
442
- Log_ErrorPrintf (" Incorrect block state for %u , expected 0xA1 got 0x% 02X" , this_block_number,
443
- df->block_allocation_state );
442
+ Log_ErrorFmt (" Incorrect block state for {} , expected 0xA1 got 0x{: 02X} " , this_block_number,
443
+ df->block_allocation_state );
444
444
return false ;
445
445
}
446
446
}
447
447
else if (i == (fi.num_blocks - 1 ))
448
448
{
449
449
if (df->block_allocation_state != 0xA3 )
450
450
{
451
- Log_ErrorPrintf (" Incorrect block state for %u, expected 0xA3 got 0x% 02X" , this_block_number,
452
- df->block_allocation_state );
451
+ Log_ErrorFmt (" Incorrect block state for %u, expected 0xA3 got 0x{: 02X} " , this_block_number,
452
+ df->block_allocation_state );
453
453
return false ;
454
454
}
455
455
}
456
456
else
457
457
{
458
458
if (df->block_allocation_state != 0xA2 )
459
459
{
460
- Log_WarningPrintf (" Incorrect block state for %u , expected 0xA2 got 0x% 02X" , this_block_number,
461
- df->block_allocation_state );
460
+ Log_ErrorFmt (" Incorrect block state for {} , expected 0xA2 got 0x{: 02X} " , this_block_number,
461
+ df->block_allocation_state );
462
462
return false ;
463
463
}
464
464
}
@@ -487,7 +487,7 @@ static bool ImportCardMCD(DataArray* data, const char* filename, std::vector<u8>
487
487
{
488
488
if (file_data.size () != DATA_SIZE)
489
489
{
490
- Log_ErrorPrintf (" Failed to import memory card from '%s ': file is incorrect size." , filename);
490
+ Log_ErrorFmt (" Failed to import memory card from '{} ': file is incorrect size." , filename);
491
491
return false ;
492
492
}
493
493
@@ -513,15 +513,15 @@ static bool ImportCardGME(DataArray* data, const char* filename, std::vector<u8>
513
513
514
514
if (file_data.size () < (sizeof (GMEHeader) + BLOCK_SIZE))
515
515
{
516
- Log_ErrorPrintf (" Failed to import GME memory card from '%s ': file is incorrect size." , filename);
516
+ Log_ErrorFmt (" Failed to import GME memory card from '{} ': file is incorrect size." , filename);
517
517
return false ;
518
518
}
519
519
520
520
// if it's too small, pad it
521
521
const u32 expected_size = sizeof (GMEHeader) + DATA_SIZE;
522
522
if (file_data.size () < expected_size)
523
523
{
524
- Log_WarningPrintf (" GME memory card '%s ' is too small (got %zu expected %u ), padding with zeroes" , filename,
524
+ Log_WarningFmt (" GME memory card '{} ' is too small (got {} expected {} ), padding with zeroes" , filename,
525
525
file_data.size (), expected_size);
526
526
file_data.resize (expected_size);
527
527
}
@@ -537,14 +537,14 @@ static bool ImportCardVGS(DataArray* data, const char* filename, std::vector<u8>
537
537
538
538
if (file_data.size () != (HEADER_SIZE + DATA_SIZE))
539
539
{
540
- Log_ErrorPrintf (" Failed to import memory card from '%s ': file is incorrect size." , filename);
540
+ Log_ErrorFmt (" Failed to import memory card from '{} ': file is incorrect size." , filename);
541
541
return false ;
542
542
}
543
543
544
544
// Connectix Virtual Game Station format (.MEM): "VgsM", 64 bytes
545
545
if (file_data[0 ] != ' V' || file_data[1 ] != ' g' || file_data[2 ] != ' s' || file_data[3 ] != ' M' )
546
546
{
547
- Log_ErrorPrintf (" Failed to import memory card from '%s ': incorrect header." , filename);
547
+ Log_ErrorFmt (" Failed to import memory card from '{} ': incorrect header." , filename);
548
548
return false ;
549
549
}
550
550
@@ -558,14 +558,14 @@ static bool ImportCardPSX(DataArray* data, const char* filename, std::vector<u8>
558
558
559
559
if (file_data.size () != (HEADER_SIZE + DATA_SIZE))
560
560
{
561
- Log_ErrorPrintf (" Failed to import memory card from '%s ': file is incorrect size." , filename);
561
+ Log_ErrorFmt (" Failed to import memory card from '{} ': file is incorrect size." , filename);
562
562
return false ;
563
563
}
564
564
565
565
// Connectix Virtual Game Station format (.MEM): "VgsM", 64 bytes
566
566
if (file_data[0 ] != ' P' || file_data[1 ] != ' S' || file_data[2 ] != ' V' )
567
567
{
568
- Log_ErrorPrintf (" Failed to import memory card from '%s ': incorrect header." , filename);
568
+ Log_ErrorFmt (" Failed to import memory card from '{} ': incorrect header." , filename);
569
569
return false ;
570
570
}
571
571
@@ -578,7 +578,7 @@ bool ImportCard(DataArray* data, const char* filename, std::vector<u8> file_data
578
578
const char * extension = std::strrchr (filename, ' .' );
579
579
if (!extension)
580
580
{
581
- Log_ErrorPrintf (" Failed to import memory card from '%s ': missing extension?" , filename);
581
+ Log_ErrorFmt (" Failed to import memory card from '{} ': missing extension?" , filename);
582
582
return false ;
583
583
}
584
584
@@ -603,7 +603,7 @@ bool ImportCard(DataArray* data, const char* filename, std::vector<u8> file_data
603
603
}
604
604
else
605
605
{
606
- Log_ErrorPrintf (" Failed to import memory card from '%s ': unknown extension?" , filename);
606
+ Log_ErrorFmt (" Failed to import memory card from '{} ': unknown extension?" , filename);
607
607
return false ;
608
608
}
609
609
}
@@ -624,7 +624,7 @@ bool ExportSave(DataArray* data, const FileInfo& fi, const char* filename)
624
624
BYTESTREAM_OPEN_ATOMIC_UPDATE | BYTESTREAM_OPEN_STREAMED);
625
625
if (!stream)
626
626
{
627
- Log_ErrorPrintf (" Failed to open '%s ' for writing." , filename);
627
+ Log_ErrorFmt (" Failed to open '{} ' for writing." , filename);
628
628
return false ;
629
629
}
630
630
@@ -635,14 +635,14 @@ bool ExportSave(DataArray* data, const FileInfo& fi, const char* filename)
635
635
std::vector<u8 > blocks;
636
636
if (!ReadFile (*data, fi, &blocks))
637
637
{
638
- Log_ErrorPrintf (" Failed to read save blocks from memory card data" );
638
+ Log_ErrorPrint (" Failed to read save blocks from memory card data" );
639
639
return false ;
640
640
}
641
641
642
642
if (!stream->Write (header.data (), static_cast <u32 >(header.size ())) ||
643
643
!stream->Write (blocks.data (), static_cast <u32 >(blocks.size ())) || !stream->Commit ())
644
644
{
645
- Log_ErrorPrintf (" Failed to write exported save to '%s '" , filename);
645
+ Log_ErrorFmt (" Failed to write exported save to '{} '" , filename);
646
646
stream->Discard ();
647
647
return false ;
648
648
}
@@ -655,42 +655,42 @@ static bool ImportSaveWithDirectoryFrame(DataArray* data, const char* filename,
655
655
// Make sure the size of the actual file is valid
656
656
if (sd.Size <= FRAME_SIZE || (sd.Size - FRAME_SIZE) % BLOCK_SIZE != 0u || (sd.Size - FRAME_SIZE) / BLOCK_SIZE > 15u )
657
657
{
658
- Log_ErrorPrintf (" Invalid size for save file '%s '" , filename);
658
+ Log_ErrorFmt (" Invalid size for save file '{} '" , filename);
659
659
return false ;
660
660
}
661
661
662
662
std::unique_ptr<ByteStream> stream = ByteStream::OpenFile (filename, BYTESTREAM_OPEN_READ | BYTESTREAM_OPEN_STREAMED);
663
663
if (!stream)
664
664
{
665
- Log_ErrorPrintf (" Failed to open '%s ' for reading" , filename);
665
+ Log_ErrorFmt (" Failed to open '{} ' for reading" , filename);
666
666
return false ;
667
667
}
668
668
669
669
DirectoryFrame df;
670
670
if (stream->Read (&df, FRAME_SIZE) != FRAME_SIZE)
671
671
{
672
- Log_ErrorPrintf (" Failed to read directory frame from '%s '" , filename);
672
+ Log_ErrorFmt (" Failed to read directory frame from '{} '" , filename);
673
673
return false ;
674
674
}
675
675
676
676
// Make sure the size reported by the directory frame is valid
677
677
if (df.file_size < BLOCK_SIZE || df.file_size % BLOCK_SIZE != 0 || df.file_size / BLOCK_SIZE > 15u )
678
678
{
679
- Log_ErrorPrintf (" Invalid size (%u bytes) reported by directory frame" , df.file_size );
679
+ Log_ErrorFmt (" Invalid size ({} bytes) reported by directory frame" , df.file_size );
680
680
return false ;
681
681
}
682
682
683
683
std::vector<u8 > blocks = std::vector<u8 >(static_cast <size_t >(df.file_size ));
684
684
if (stream->Read (blocks.data (), df.file_size ) != df.file_size )
685
685
{
686
- Log_ErrorPrintf (" Failed to read block bytes from '%s '" , filename);
686
+ Log_ErrorFmt (" Failed to read block bytes from '{} '" , filename);
687
687
return false ;
688
688
}
689
689
690
690
const u32 num_blocks = (static_cast <u32 >(blocks.size ()) + (BLOCK_SIZE - 1 )) / BLOCK_SIZE;
691
691
if (GetFreeBlockCount (*data) < num_blocks)
692
692
{
693
- Log_ErrorPrintf (" Failed to write file to memory card: insufficient free blocks" );
693
+ Log_ErrorPrint (" Failed to write file to memory card: insufficient free blocks" );
694
694
return false ;
695
695
}
696
696
@@ -702,7 +702,7 @@ static bool ImportSaveWithDirectoryFrame(DataArray* data, const char* filename,
702
702
{
703
703
if (!fi.deleted )
704
704
{
705
- Log_ErrorPrintf (" Save file with the same name '%s ' already exists in memory card" , fi.filename .c_str ());
705
+ Log_ErrorFmt (" Save file with the same name '{} ' already exists in memory card" , fi.filename .c_str ());
706
706
return false ;
707
707
}
708
708
@@ -719,7 +719,7 @@ static bool ImportRawSave(DataArray* data, const char* filename, const FILESYSTE
719
719
std::string save_name (Path::GetFileTitle (filename));
720
720
if (save_name.length () == 0 )
721
721
{
722
- Log_ErrorPrintf (" Invalid filename: '%s '" , filename);
722
+ Log_ErrorFmt (" Invalid filename: '{} '" , filename);
723
723
return false ;
724
724
}
725
725
@@ -729,14 +729,14 @@ static bool ImportRawSave(DataArray* data, const char* filename, const FILESYSTE
729
729
std::optional<std::vector<u8 >> blocks = FileSystem::ReadBinaryFile (filename);
730
730
if (!blocks.has_value ())
731
731
{
732
- Log_ErrorPrintf (" Failed to read '%s '" , filename);
732
+ Log_ErrorFmt (" Failed to read '{} '" , filename);
733
733
return false ;
734
734
}
735
735
736
736
const u32 num_blocks = (static_cast <u32 >(blocks->size ()) + (BLOCK_SIZE - 1 )) / BLOCK_SIZE;
737
737
if (GetFreeBlockCount (*data) < num_blocks)
738
738
{
739
- Log_ErrorPrintf (" Failed to write file to memory card: insufficient free blocks" );
739
+ Log_ErrorPrint (" Failed to write file to memory card: insufficient free blocks" );
740
740
return false ;
741
741
}
742
742
@@ -748,7 +748,7 @@ static bool ImportRawSave(DataArray* data, const char* filename, const FILESYSTE
748
748
{
749
749
if (!fi.deleted )
750
750
{
751
- Log_ErrorPrintf (" Save file with the same name '%s ' already exists in memory card" , fi.filename . c_str () );
751
+ Log_ErrorFmt (" Save file with the same name '{} ' already exists in memory card" , fi.filename );
752
752
return false ;
753
753
}
754
754
@@ -764,14 +764,14 @@ bool ImportSave(DataArray* data, const char* filename)
764
764
FILESYSTEM_STAT_DATA sd;
765
765
if (!FileSystem::StatFile (filename, &sd))
766
766
{
767
- Log_ErrorPrintf (" Failed to stat file '%s '" , filename);
767
+ Log_ErrorFmt (" Failed to stat file '{} '" , filename);
768
768
return false ;
769
769
}
770
770
771
771
// Make sure the size of the actual file is valid
772
772
if (sd.Size == 0 )
773
773
{
774
- Log_ErrorPrintf (" Invalid size for save file '%s '" , filename);
774
+ Log_ErrorFmt (" Invalid size for save file '{} '" , filename);
775
775
return false ;
776
776
}
777
777
@@ -785,7 +785,7 @@ bool ImportSave(DataArray* data, const char* filename)
785
785
}
786
786
else
787
787
{
788
- Log_ErrorPrintf (" Unknown save format for '%s '" , filename);
788
+ Log_ErrorFmt (" Unknown save format for '{} '" , filename);
789
789
return false ;
790
790
}
791
791
}
0 commit comments