Merge pull request #1092 from Bigpet/localdev

Change `GetDeviceLocal` device selection
This commit is contained in:
B1ackDaemon 2015-05-24 02:09:51 +03:00
commit dcad0e286a
2 changed files with 14 additions and 17 deletions

View file

@ -386,30 +386,30 @@ vfsDevice* VFS::GetDevice(const std::string& ps3_path, std::string& path) const
vfsDevice* VFS::GetDeviceLocal(const std::string& local_path, std::string& path) const vfsDevice* VFS::GetDeviceLocal(const std::string& local_path, std::string& path) const
{ {
size_t max_eq = 0; int max_eq = -1;
int max_i = -1; int max_i = -1;
std::vector<std::string> local_path_blocks = simplify_path_blocks(local_path); std::vector<std::string> local_path_blocks = simplify_path_blocks(local_path);
for (u32 i = 0; i < m_devices.size(); ++i) for (u32 i = 0; i < m_devices.size(); ++i)
{ {
std::vector<std::string> dev_local_path_blocks_blocks = simplify_path_blocks(m_devices[i]->GetLocalPath()); std::vector<std::string> dev_local_path_blocks = simplify_path_blocks(m_devices[i]->GetLocalPath());
if (local_path_blocks.size() < dev_local_path_blocks_blocks.size()) if (local_path_blocks.size() < dev_local_path_blocks.size())
continue; continue;
size_t eq = 0; int dev_blocks = dev_local_path_blocks.size();
for (; eq < dev_local_path_blocks_blocks.size(); ++eq)
{
if (strcmp(local_path_blocks[eq].c_str(), dev_local_path_blocks_blocks[eq].c_str()))
{
break;
}
}
if (eq > max_eq) bool prefix_equal = std::equal(
std::begin(dev_local_path_blocks),
std::end(dev_local_path_blocks),
std::begin(local_path_blocks),
[](const std::string& a, const std::string& b){ return strcmp(a.c_str(), b.c_str()) == 0; }
);
if (prefix_equal && dev_blocks > max_eq)
{ {
max_eq = eq; max_eq = dev_blocks;
max_i = i; max_i = i;
} }
} }

View file

@ -265,10 +265,7 @@ void Emulator::Load()
if (m_elf_path.empty()) if (m_elf_path.empty())
{ {
if (!GetVFS().GetDeviceLocal(m_path, m_elf_path)) GetVFS().GetDeviceLocal(m_path, m_elf_path);
{
m_elf_path = "/host_root/" + m_path; // should be probably app_home
}
LOG_NOTICE(LOADER, "Elf path: %s", m_elf_path); LOG_NOTICE(LOADER, "Elf path: %s", m_elf_path);
} }