mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-04-20 15:51:17 +02:00
Fix orphan check
Fixes orphan check being broken after changes in 367b57ca8905dde5d4a5ba7d97fa9aa9754863b3
This commit is contained in:
parent
759bb1d992
commit
0bae0c2160
@ -49,12 +49,12 @@ class gameDetails
|
||||
std::vector<gameFile> getGameFileVector();
|
||||
std::vector<gameFile> getGameFileVectorFiltered(const unsigned int& iType);
|
||||
void filterWithType(const unsigned int& iType);
|
||||
std::string makeCustomFilepath(const std::string& filename, const gameDetails& gd, const DirectoryConfig& dirConf);
|
||||
virtual ~gameDetails();
|
||||
protected:
|
||||
void filterListWithPriorities(std::vector<gameFile>& list, const gameSpecificConfig& config);
|
||||
void filterListWithType(std::vector<gameFile>& list, const unsigned int& iType);
|
||||
std::string makeFilepath(const gameFile& gf, const DirectoryConfig& dirConf);
|
||||
std::string makeCustomFilepath(const std::string& filename, const gameDetails& gd, const DirectoryConfig& dirConf);
|
||||
private:
|
||||
std::string serialsFilepath;
|
||||
std::string logoFilepath;
|
||||
|
@ -67,7 +67,6 @@ namespace Util
|
||||
int getGameSpecificConfig(std::string gamename, gameSpecificConfig* conf, std::string directory = std::string());
|
||||
int replaceString(std::string& str, const std::string& to_replace, const std::string& replace_with);
|
||||
int replaceAllString(std::string& str, const std::string& to_replace, const std::string& replace_with);
|
||||
void filepathReplaceReservedStrings(std::string& str, const std::string& gamename, const unsigned int& platformId = 0, const std::string& dlcname = "");
|
||||
void setFilePermissions(const boost::filesystem::path& path, const boost::filesystem::perms& permissions);
|
||||
int getTerminalWidth();
|
||||
void getManualUrlsFromJSON(const Json::Value &root, std::vector<std::string> &urls);
|
||||
|
@ -1712,8 +1712,7 @@ void Downloader::checkOrphans()
|
||||
}
|
||||
for (unsigned int j = 0; j < platformIds.size(); ++j)
|
||||
{
|
||||
std::string directory = config.dirConf.sDirectory + "/" + config.dirConf.sGameSubdir + "/";
|
||||
Util::filepathReplaceReservedStrings(directory, games[i].gamename, platformIds[j]);
|
||||
std::string directory = games[i].makeCustomFilepath("", games[i], config.dirConf);
|
||||
boost::filesystem::path path (directory);
|
||||
if (boost::filesystem::exists(path))
|
||||
{
|
||||
|
62
src/util.cpp
62
src/util.cpp
@ -371,72 +371,12 @@ int Util::replaceAllString(std::string& str, const std::string& to_replace, cons
|
||||
|
||||
do {
|
||||
str.replace(str.begin()+pos, str.begin()+pos+to_replace.length(), replace_with);
|
||||
|
||||
pos = str.find(to_replace, pos + to_replace.length());
|
||||
pos = str.find(to_replace);
|
||||
} while(pos != std::string::npos);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Util::filepathReplaceReservedStrings(std::string& str, const std::string& gamename, const unsigned int& platformId, const std::string& dlcname)
|
||||
{
|
||||
std::string platform;
|
||||
for (unsigned int i = 0; i < GlobalConstants::PLATFORMS.size(); ++i)
|
||||
{
|
||||
if ((platformId & GlobalConstants::PLATFORMS[i].id) == GlobalConstants::PLATFORMS[i].id)
|
||||
{
|
||||
platform = boost::algorithm::to_lower_copy(GlobalConstants::PLATFORMS[i].str);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (platform.empty())
|
||||
{
|
||||
if (str.find("%gamename%/%platform%") != std::string::npos)
|
||||
platform = "";
|
||||
else
|
||||
platform = "no_platform";
|
||||
}
|
||||
|
||||
// Don't save certain files in "no_platform" folder
|
||||
if (
|
||||
str.rfind("/icon.png") != std::string::npos
|
||||
|| str.rfind("/logo.jpg") != std::string::npos
|
||||
|| str.rfind("/product.json") != std::string::npos
|
||||
)
|
||||
platform = "";
|
||||
|
||||
std::string gamename_firstletter;
|
||||
if (!gamename.empty())
|
||||
{
|
||||
if (std::isdigit(gamename.front()))
|
||||
gamename_firstletter = "0";
|
||||
else
|
||||
gamename_firstletter = gamename.front();
|
||||
}
|
||||
|
||||
if (str.find("%gamename_transformed%") != std::string::npos || str.find("%gamename_transformed_firstletter%") != std::string::npos)
|
||||
{
|
||||
std::string gamename_transformed = transformGamename(gamename);
|
||||
std::string gamename_transformed_firstletter;
|
||||
if (!gamename_transformed.empty())
|
||||
{
|
||||
if (std::isdigit(gamename_transformed.front()))
|
||||
gamename_transformed_firstletter = "0";
|
||||
else
|
||||
gamename_transformed_firstletter = gamename_transformed.front();
|
||||
}
|
||||
|
||||
while (Util::replaceString(str, "%gamename_transformed%", gamename_transformed));
|
||||
while (Util::replaceString(str, "%gamename_transformed_firstletter%", gamename_transformed_firstletter));
|
||||
}
|
||||
|
||||
while (Util::replaceString(str, "%gamename_firstletter%", gamename_firstletter));
|
||||
while (Util::replaceString(str, "%gamename%", gamename));
|
||||
while (Util::replaceString(str, "%dlcname%", dlcname));
|
||||
while (Util::replaceString(str, "%platform%", platform));
|
||||
while (Util::replaceString(str, "//", "/")); // Replace any double slashes with single slash
|
||||
}
|
||||
|
||||
void Util::setFilePermissions(const boost::filesystem::path& path, const boost::filesystem::perms& permissions)
|
||||
{
|
||||
if (boost::filesystem::exists(path))
|
||||
|
Loading…
x
Reference in New Issue
Block a user