Tested Enable/Disable this Custom EmulationDir Feature, and it can check whether directory exists. But there is still problem with its log.

This commit is contained in:
luxsie 2015-04-10 23:56:38 +08:00
parent 64ab14b237
commit ea17e08ae6
2 changed files with 25 additions and 7 deletions

View File

@ -6,6 +6,7 @@
#include "Ini.h" #include "Ini.h"
#include "Emu/System.h" #include "Emu/System.h"
#include "Utilities/Log.h" #include "Utilities/Log.h"
#include <sys/stat.h> // To check whether directory exists
#undef CreateFile #undef CreateFile
@ -477,17 +478,34 @@ void VFS::SaveLoadDevices(std::vector<VFSManagerEntry>& res, bool is_load)
entries_count.SaveValue(count); entries_count.SaveValue(count);
} }
//Custom EmulationDir. should check if that is a valid directory. // Custom EmulationDir.
// TODO:: should have a better log that would show results before loading a game?
if (Ini.SysEmulationDirPathEnable.GetValue()) if (Ini.SysEmulationDirPathEnable.GetValue())
{ {
if (Ini.SysEmulationDirPath.GetValue().empty()) std::string EmulationDir = Ini.SysEmulationDirPath.GetValue();
if (EmulationDir.empty())
Ini.SysEmulationDirPath.SetValue(Emu.GetEmulatorPath()); Ini.SysEmulationDirPath.SetValue(Emu.GetEmulatorPath());
LOG_NOTICE(GENERAL, "EmualtionDir: Custom EmulationDir is On, Binded $(EmulatorDir) to %s.", Ini.SysEmulationDirPath.GetValue()); struct stat fstatinfo;
if ((stat(EmulationDir.c_str(), &fstatinfo)))
{
LOG_NOTICE(GENERAL, "Custom EmualtionDir: Tried %s but it doesn't exists. Maybe you add some not needed chars like '\"'?");
Ini.SysEmulationDirPathEnable.SetValue(false);
}
else if (fstatinfo.st_mode & S_IFDIR)
LOG_NOTICE(GENERAL, "Custom EmualtionDir: On, Binded $(EmulatorDir) to %s.", EmulationDir);
else
{
// If that is not directory turn back to use original one.
LOG_NOTICE(GENERAL, "Custom EmulationDir: Cause path %s is not a valid directory.", EmulationDir);
Ini.SysEmulationDirPathEnable.SetValue(false);
}
} }
else // I left this to check again just to catch those failed in directory checks.
if (!Ini.SysEmulationDirPathEnable.GetValue())
{ {
LOG_NOTICE(GENERAL, "EmualtionDir: Custom EmulationDir is Off, Binded $(EmulatorDir) to %s.", Emu.GetEmulatorPath()); LOG_NOTICE(GENERAL, "Custom EmualtionDir: Off, Binded $(EmulatorDir) to %s.", Emu.GetEmulatorPath());
} }
for(int i=0; i<count; ++i) for(int i=0; i<count; ++i)
{ {
IniEntry<std::string> entry_path; IniEntry<std::string> entry_path;

View File

@ -437,8 +437,8 @@ void MainFrame::Config(wxCommandEvent& WXUNUSED(event))
wxCheckBox* chbox_dbg_ap_functioncall = new wxCheckBox(p_hle, wxID_ANY, "Auto Pause at Function Call"); wxCheckBox* chbox_dbg_ap_functioncall = new wxCheckBox(p_hle, wxID_ANY, "Auto Pause at Function Call");
//Custom EmulationDir //Custom EmulationDir
wxCheckBox* chbox_emulationdir_enable = new wxCheckBox(p_system, wxID_ANY, "Use Custom EmulationDir Path?"); wxCheckBox* chbox_emulationdir_enable = new wxCheckBox(p_system, wxID_ANY, "Use Path Below as EmulationDir ? (Need Restart)");
wxTextCtrl* txt_emulationdir_path = new wxTextCtrl(p_system, wxID_ANY, "EmulationDir Path, Need Restart"); wxTextCtrl* txt_emulationdir_path = new wxTextCtrl(p_system, wxID_ANY, Emu.GetEmulatorPath());
cbox_cpu_decoder->Append("PPU Interpreter"); cbox_cpu_decoder->Append("PPU Interpreter");
cbox_cpu_decoder->Append("PPU Interpreter 2"); cbox_cpu_decoder->Append("PPU Interpreter 2");