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 "Emu/System.h"
#include "Utilities/Log.h"
#include <sys/stat.h> // To check whether directory exists
#undef CreateFile
@ -477,17 +478,34 @@ void VFS::SaveLoadDevices(std::vector<VFSManagerEntry>& res, bool is_load)
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.SysEmulationDirPath.GetValue().empty())
std::string EmulationDir = Ini.SysEmulationDirPath.GetValue();
if (EmulationDir.empty())
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)
{
IniEntry<std::string> entry_path;