mirror of
https://github.com/jpd002/Play-.git
synced 2025-04-28 21:57:57 +03:00
59 lines
1.5 KiB
C++
59 lines
1.5 KiB
C++
#include "BootablesProcesses.h"
|
|
#include "BootablesDbClient.h"
|
|
#include "LocalGamesDbClient.h"
|
|
#include "DiskUtils.h"
|
|
|
|
//Jobs
|
|
// Scan for new games (from input directory)
|
|
// Remove games that might not be available anymore
|
|
// Extract game ids from disk images
|
|
// Pull disc cover URLs and titles from GamesDb/TheGamesDb
|
|
|
|
void ScanBootables(const boost::filesystem::path& parentPath)
|
|
{
|
|
for(auto pathIterator = boost::filesystem::directory_iterator(parentPath);
|
|
pathIterator != boost::filesystem::directory_iterator(); pathIterator++)
|
|
{
|
|
auto& path = pathIterator->path();
|
|
if(boost::filesystem::is_directory(path))
|
|
{
|
|
ScanBootables(path);
|
|
continue;
|
|
}
|
|
auto pathExtension = path.extension();
|
|
if(
|
|
(pathExtension != ".isz") &&
|
|
(pathExtension != ".elf")
|
|
) continue;
|
|
BootablesDb::CClient::GetInstance().RegisterBootable(path);
|
|
}
|
|
}
|
|
|
|
void ExtractDiscIds()
|
|
{
|
|
auto bootables = BootablesDb::CClient::GetInstance().GetBootables();
|
|
for(const auto& bootable : bootables)
|
|
{
|
|
std::string discId;
|
|
if(!DiskUtils::TryGetDiskId(bootable.path, &discId)) continue;
|
|
BootablesDb::CClient::GetInstance().SetDiscId(bootable.path, discId.c_str());
|
|
}
|
|
}
|
|
|
|
void FetchGameTitles()
|
|
{
|
|
auto bootables = BootablesDb::CClient::GetInstance().GetBootables();
|
|
for(const auto& bootable : bootables)
|
|
{
|
|
if(bootable.discId.empty()) continue;
|
|
try
|
|
{
|
|
auto game = LocalGamesDb::CClient::GetInstance().GetGame(bootable.discId.c_str());
|
|
BootablesDb::CClient::GetInstance().SetTitle(bootable.path, game.title.c_str());
|
|
}
|
|
catch(...)
|
|
{
|
|
//Log or something?
|
|
}
|
|
}
|
|
}
|