Create filepaths in gameDetails class

Add makeFilepaths method to gameDetails class
Add setFilepath and getFilepath methods to gameFile class
This commit is contained in:
Sude 2014-09-19 21:08:46 +03:00
parent 7a00b59345
commit 810506b74b
5 changed files with 122 additions and 70 deletions

View File

@ -3,6 +3,7 @@
#include "globalconstants.h" #include "globalconstants.h"
#include "gamefile.h" #include "gamefile.h"
#include "config.h"
#include <iostream> #include <iostream>
#include <vector> #include <vector>
@ -10,6 +11,7 @@
class gameDetails class gameDetails
{ {
public: public:
gameDetails();
std::vector<gameFile> extras; std::vector<gameFile> extras;
std::vector<gameFile> installers; std::vector<gameFile> installers;
std::vector<gameFile> patches; std::vector<gameFile> patches;
@ -18,6 +20,8 @@ class gameDetails
std::string gamename; std::string gamename;
std::string title; std::string title;
std::string icon;; std::string icon;;
void makeFilepaths(const Config& config);
virtual ~gameDetails();
protected: protected:
private: private:
}; };

View File

@ -18,9 +18,12 @@ class gameFile
unsigned int platform; unsigned int platform;
unsigned int language; unsigned int language;
int silent; int silent;
void setFilepath(const std::string& path);
std::string getFilepath();
virtual ~gameFile(); virtual ~gameFile();
protected: protected:
private: private:
std::string filepath;
}; };
#endif // GAMEFILE_H #endif // GAMEFILE_H

View File

@ -239,6 +239,9 @@ int Downloader::getGameDetails()
game.dlcs.push_back(dlc); game.dlcs.push_back(dlc);
} }
} }
game.makeFilepaths(config);
if (!config.bUpdateCheck) if (!config.bUpdateCheck)
games.push_back(game); games.push_back(game);
else else
@ -289,8 +292,8 @@ void Downloader::listGames()
{ {
if (!config.bUpdateCheck || games[i].installers[j].updated) // Always list updated files if (!config.bUpdateCheck || games[i].installers[j].updated) // Always list updated files
{ {
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].installers[j].path, games[i].gamename); std::string filepath = games[i].installers[j].getFilepath();
if (config.blacklist.isBlacklisted(games[i].installers[j].path, games[i].gamename)) if (config.blacklist.isBlacklisted(filepath))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -320,9 +323,8 @@ void Downloader::listGames()
std::cout << "extras: " << std::endl; std::cout << "extras: " << std::endl;
for (unsigned int j = 0; j < games[i].extras.size(); ++j) for (unsigned int j = 0; j < games[i].extras.size(); ++j)
{ {
std::string subdir = config.bSubDirectories ? "extras" : ""; std::string filepath = games[i].extras[j].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].extras[j].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -342,9 +344,8 @@ void Downloader::listGames()
std::cout << "patches: " << std::endl; std::cout << "patches: " << std::endl;
for (unsigned int j = 0; j < games[i].patches.size(); ++j) for (unsigned int j = 0; j < games[i].patches.size(); ++j)
{ {
std::string subdir = config.bSubDirectories ? "patches" : ""; std::string filepath = games[i].patches[j].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].patches[j].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -373,9 +374,8 @@ void Downloader::listGames()
std::cout << "language packs: " << std::endl; std::cout << "language packs: " << std::endl;
for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j) for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j)
{ {
std::string subdir = config.bSubDirectories ? "languagepacks" : ""; std::string filepath = games[i].languagepacks[j].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].languagepacks[j].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -396,9 +396,8 @@ void Downloader::listGames()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].installers.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].installers.size(); ++k)
{ {
std::string subdir = (config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename : ""); std::string filepath = games[i].dlcs[j].installers[k].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].installers[k].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].dlcs[j].installers[k].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -415,9 +414,8 @@ void Downloader::listGames()
} }
for (unsigned int k = 0; k < games[i].dlcs[j].patches.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].patches.size(); ++k)
{ {
std::string subdir = config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename + "/patches" : ""; std::string filepath = games[i].dlcs[j].patches[k].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].patches[k].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath)) {
if (config.blacklist.isBlacklisted(games[i].dlcs[j].patches[k].path, games[i].gamename, subdir)) {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
continue; continue;
@ -432,9 +430,8 @@ void Downloader::listGames()
} }
for (unsigned int k = 0; k < games[i].dlcs[j].extras.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].extras.size(); ++k)
{ {
std::string subdir = config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename + "/extras" : ""; std::string filepath = games[i].dlcs[j].extras[k].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].extras[k].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath)) {
if (config.blacklist.isBlacklisted(games[i].dlcs[j].extras[k].path, games[i].gamename, subdir)) {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
continue; continue;
@ -475,8 +472,8 @@ void Downloader::repair()
{ {
for (unsigned int j = 0; j < games[i].installers.size(); ++j) for (unsigned int j = 0; j < games[i].installers.size(); ++j)
{ {
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].installers[j].path, games[i].gamename); std::string filepath = games[i].installers[j].getFilepath();
if (config.blacklist.isBlacklisted(games[i].installers[j].path, games[i].gamename)) if (config.blacklist.isBlacklisted(filepath))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -519,9 +516,8 @@ void Downloader::repair()
{ {
for (unsigned int j = 0; j < games[i].extras.size(); ++j) for (unsigned int j = 0; j < games[i].extras.size(); ++j)
{ {
std::string subdir = config.bSubDirectories ? "extras" : ""; std::string filepath = games[i].extras[j].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].extras[j].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -546,9 +542,8 @@ void Downloader::repair()
{ {
for (unsigned int j = 0; j < games[i].patches.size(); ++j) for (unsigned int j = 0; j < games[i].patches.size(); ++j)
{ {
std::string subdir = config.bSubDirectories ? "patches" : ""; std::string filepath = games[i].patches[j].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].patches[j].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -585,9 +580,8 @@ void Downloader::repair()
{ {
for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j) for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j)
{ {
std::string subdir = config.bSubDirectories ? "languagepacks" : ""; std::string filepath = games[i].languagepacks[j].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].languagepacks[j].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -614,9 +608,8 @@ void Downloader::repair()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].installers.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].installers.size(); ++k)
{ {
std::string subdir = (config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename : ""); std::string filepath = games[i].dlcs[j].installers[k].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].installers[k].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].dlcs[j].installers[k].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -657,9 +650,8 @@ void Downloader::repair()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].patches.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].patches.size(); ++k)
{ {
std::string subdir = config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename + "/patches" : ""; std::string filepath = games[i].dlcs[j].patches[k].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].patches[k].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath)) {
if (config.blacklist.isBlacklisted(games[i].dlcs[j].patches[k].path, games[i].gamename, subdir)) {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
continue; continue;
@ -693,9 +685,8 @@ void Downloader::repair()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].extras.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].extras.size(); ++k)
{ {
std::string subdir = config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename + "/extras" : ""; std::string filepath = games[i].dlcs[j].extras[k].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].extras[k].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath)) {
if (config.blacklist.isBlacklisted(games[i].dlcs[j].extras[k].path, games[i].gamename, subdir)) {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
continue; continue;
@ -731,7 +722,7 @@ void Downloader::download()
if (!games[i].installers.empty()) if (!games[i].installers.empty())
{ {
// Take path from installer path because for some games the base directory for installer/extra path is not "gamename" // Take path from installer path because for some games the base directory for installer/extra path is not "gamename"
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].installers[0].path, games[i].gamename); std::string filepath = games[i].installers[0].getFilepath();
// Get base directory from filepath // Get base directory from filepath
boost::match_results<std::string::const_iterator> what; boost::match_results<std::string::const_iterator> what;
@ -751,8 +742,8 @@ void Downloader::download()
if (config.bUpdateCheck && !games[i].installers[j].updated) if (config.bUpdateCheck && !games[i].installers[j].updated)
continue; continue;
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].installers[j].path, games[i].gamename); std::string filepath = games[i].installers[j].getFilepath();
if (config.blacklist.isBlacklisted(games[i].installers[j].path, games[i].gamename)) if (config.blacklist.isBlacklisted(filepath))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -796,9 +787,8 @@ void Downloader::download()
continue; continue;
} }
std::string subdir = config.bSubDirectories ? "extras" : ""; std::string filepath = games[i].extras[j].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].extras[j].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -841,9 +831,8 @@ void Downloader::download()
continue; continue;
} }
std::string subdir = config.bSubDirectories ? "patches" : ""; std::string filepath = games[i].patches[j].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].patches[j].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -878,9 +867,8 @@ void Downloader::download()
continue; continue;
} }
std::string subdir = config.bSubDirectories ? "languagepacks" : ""; std::string filepath = games[i].languagepacks[j].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].languagepacks[j].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -909,9 +897,8 @@ void Downloader::download()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].installers.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].installers.size(); ++k)
{ {
std::string subdir = config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename : ""; std::string filepath = games[i].dlcs[j].installers[k].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].installers[k].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].dlcs[j].installers[k].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -945,9 +932,8 @@ void Downloader::download()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].patches.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].patches.size(); ++k)
{ {
std::string subdir = config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename + "/patches" : ""; std::string filepath = games[i].dlcs[j].patches[k].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].patches[k].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].dlcs[j].patches[k].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -981,9 +967,8 @@ void Downloader::download()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].extras.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].extras.size(); ++k)
{ {
std::string subdir = config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename + "/extras" : ""; std::string filepath = games[i].dlcs[j].extras[k].getFilepath();
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].extras[k].path, games[i].gamename, subdir); if (config.blacklist.isBlacklisted(filepath))
if (config.blacklist.isBlacklisted(games[i].dlcs[j].extras[k].path, games[i].gamename, subdir))
{ {
if (config.bVerbose) if (config.bVerbose)
std::cout << "skipped blacklisted file " << filepath << std::endl; std::cout << "skipped blacklisted file " << filepath << std::endl;
@ -2401,7 +2386,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int j = 0; j < games[i].installers.size(); ++j) for (unsigned int j = 0; j < games[i].installers.size(); ++j)
{ {
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].installers[j].path, games[i].gamename); boost::filesystem::path filepath = games[i].installers[j].getFilepath();
std::string remoteHash; std::string remoteHash;
std::string localHash; std::string localHash;
@ -2431,7 +2416,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int j = 0; j < games[i].extras.size(); ++j) for (unsigned int j = 0; j < games[i].extras.size(); ++j)
{ {
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, config.bSubDirectories ? "extras" : ""); boost::filesystem::path filepath = games[i].extras[j].getFilepath();
std::string localHash = this->getLocalFileHash(filepath.string(), games[i].gamename); std::string localHash = this->getLocalFileHash(filepath.string(), games[i].gamename);
size_t filesize; size_t filesize;
@ -2452,7 +2437,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int j = 0; j < games[i].patches.size(); ++j) for (unsigned int j = 0; j < games[i].patches.size(); ++j)
{ {
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, config.bSubDirectories ? "patches" : ""); boost::filesystem::path filepath = games[i].patches[j].getFilepath();
std::string localHash = this->getLocalFileHash(filepath.string(), games[i].gamename); std::string localHash = this->getLocalFileHash(filepath.string(), games[i].gamename);
size_t filesize; size_t filesize;
@ -2473,7 +2458,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j) for (unsigned int j = 0; j < games[i].languagepacks.size(); ++j)
{ {
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, config.bSubDirectories ? "languagepacks" : ""); boost::filesystem::path filepath = games[i].languagepacks[j].getFilepath();
std::string localHash = this->getLocalFileHash(filepath.string(), games[i].gamename); std::string localHash = this->getLocalFileHash(filepath.string(), games[i].gamename);
size_t filesize; size_t filesize;
@ -2498,7 +2483,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].installers.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].installers.size(); ++k)
{ {
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].installers[k].path, games[i].gamename, config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename : ""); boost::filesystem::path filepath = games[i].dlcs[j].installers[k].getFilepath();
std::string remoteHash; std::string remoteHash;
std::string localHash; std::string localHash;
@ -2528,7 +2513,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].patches.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].patches.size(); ++k)
{ {
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].patches[k].path, games[i].gamename, config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename + "/patches" : ""); boost::filesystem::path filepath = games[i].dlcs[j].patches[k].getFilepath();
std::string localHash = this->getLocalFileHash(filepath.string(), games[i].dlcs[j].gamename); std::string localHash = this->getLocalFileHash(filepath.string(), games[i].dlcs[j].gamename);
size_t filesize; size_t filesize;
@ -2549,7 +2534,7 @@ void Downloader::checkStatus()
{ {
for (unsigned int k = 0; k < games[i].dlcs[j].extras.size(); ++k) for (unsigned int k = 0; k < games[i].dlcs[j].extras.size(); ++k)
{ {
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].dlcs[j].extras[k].path, games[i].gamename, config.bSubDirectories ? "dlc/" + games[i].dlcs[j].gamename + "/extras" : ""); boost::filesystem::path filepath = games[i].dlcs[j].extras[k].getFilepath();
std::string localHash = this->getLocalFileHash(filepath.string(), games[i].dlcs[j].gamename); std::string localHash = this->getLocalFileHash(filepath.string(), games[i].dlcs[j].gamename);
size_t filesize; size_t filesize;

View File

@ -1,6 +1,7 @@
#include "gamedetails.h" #include "gamedetails.h"
#include "util.h"
/*gameDetails::gameDetails() gameDetails::gameDetails()
{ {
//ctor //ctor
} }
@ -8,4 +9,53 @@
gameDetails::~gameDetails() gameDetails::~gameDetails()
{ {
//dtor //dtor
}*/ }
void gameDetails::makeFilepaths(const Config& config)
{
std::string filepath;
for (unsigned int i = 0; i < this->installers.size(); ++i)
{
filepath = Util::makeFilepath(config.sDirectory, this->installers[i].path, this->gamename);
this->installers[i].setFilepath(filepath);
}
for (unsigned int i = 0; i < this->extras.size(); ++i)
{
filepath = Util::makeFilepath(config.sDirectory, this->extras[i].path, this->gamename, config.bSubDirectories ? "extras" : "");
this->extras[i].setFilepath(filepath);
}
for (unsigned int i = 0; i < this->patches.size(); ++i)
{
filepath = Util::makeFilepath(config.sDirectory, this->patches[i].path, this->gamename, config.bSubDirectories ? "patches" : "");
this->patches[i].setFilepath(filepath);
}
for (unsigned int i = 0; i < this->languagepacks.size(); ++i)
{
filepath = Util::makeFilepath(config.sDirectory, this->languagepacks[i].path, this->gamename, config.bSubDirectories ? "languagepacks" : "");
}
for (unsigned int i = 0; i < this->dlcs.size(); ++i)
{
for (unsigned int j = 0; j < this->dlcs[i].installers.size(); ++j)
{
filepath = Util::makeFilepath(config.sDirectory, this->dlcs[i].installers[j].path, this->gamename, config.bSubDirectories ? "dlc/" + this->dlcs[i].gamename : "");
this->dlcs[i].installers[j].setFilepath(filepath);
}
for (unsigned int j = 0; j < this->dlcs[i].patches.size(); ++j)
{
filepath = Util::makeFilepath(config.sDirectory, this->dlcs[i].patches[j].path, this->gamename, config.bSubDirectories ? "dlc/" + this->dlcs[i].gamename + "/patches" : "");
this->dlcs[i].patches[j].setFilepath(filepath);
}
for (unsigned int j = 0; j < this->dlcs[i].extras.size(); ++j)
{
filepath = Util::makeFilepath(config.sDirectory, this->dlcs[i].extras[j].path, this->gamename, config.bSubDirectories ? "dlc/" + this->dlcs[i].gamename + "/extras" : "");
this->dlcs[i].extras[j].setFilepath(filepath);
}
}
}

View File

@ -16,3 +16,13 @@ gameFile::~gameFile()
{ {
//dtor //dtor
} }
void gameFile::setFilepath(const std::string& path)
{
this->filepath = path;
}
std::string gameFile::getFilepath()
{
return this->filepath;
}