MCPcopy Create free account
hub / github.com/0ldsk00l/nestopia / LoadImageData

Method LoadImageData

source/win32/NstManagerEmulator.cpp:815–888  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

813 }
814
815 void Emulator::LoadImageData(Nes::User::File& context) const
816 {
817 Path path( settings.paths.save );
818
819 cstring desc = "image save";
820
821 switch (context.GetAction())
822 {
823 case Nes::User::File::LOAD_BATTERY:
824
825 desc = "battery";
826 break;
827
828 case Nes::User::File::LOAD_EEPROM:
829
830 desc = "EEPROM";
831 break;
832
833 case Nes::User::File::LOAD_TAPE:
834
835 desc = "tape";
836 path = settings.paths.tape;
837 break;
838
839 case Nes::User::File::LOAD_TURBOFILE:
840
841 desc = "turbo file";
842
843 if (path.Length())
844 path.Extension() = L"tf";
845
846 break;
847 }
848
849 if (path.FileExists())
850 {
851 try
852 {
853 Io::Stream::In stream( path );
854 const Nes::Result result = context.SetContent( stream );
855
856 if (NES_SUCCEEDED(result))
857 {
858 Io::Log() << "Emulator: loaded " << desc << " data from \"" << path << "\"\r\n";
859 }
860 else
861 {
862 HeapString msg( Resource::String( IDS_CARTRIDGE_LOAD_FAILED ).Invoke( path ) );
863
864 if (const uint id = ResultToString( result ))
865 msg << ' ' << Resource::String( id );
866
867 Window::User::Warn( msg.Ptr() );
868 }
869 }
870 catch (Io::File::Exception id)
871 {
872 HeapString msg;

Callers 1

DoFileIOMethod · 0.80

Calls 9

WarnFunction · 0.85
ExtensionMethod · 0.80
FileExistsMethod · 0.80
LogClass · 0.70
StringClass · 0.70
GetActionMethod · 0.45
LengthMethod · 0.45
SetContentMethod · 0.45
PtrMethod · 0.45

Tested by

no test coverage detected