mirror of
https://github.com/Sude-/lgogdownloader.git
synced 2025-02-02 05:52:31 +01:00
Use subdirectories for extras, patches and languagepacks
The simple extras detection in Util::makeFilePath is replaced with argument for setting subdirectory
This commit is contained in:
parent
cfe4311209
commit
1c26af48d2
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
namespace Util
|
namespace Util
|
||||||
{
|
{
|
||||||
std::string makeFilepath(const std::string& directory, const std::string& path, const std::string& gamename);
|
std::string makeFilepath(const std::string& directory, const std::string& path, const std::string& gamename, std::string subdirectory = "");
|
||||||
std::string getFileHash(const std::string& filename, unsigned hash_id);
|
std::string getFileHash(const std::string& filename, unsigned hash_id);
|
||||||
std::string getChunkHash(unsigned char* chunk, size_t chunk_size, unsigned hash_id);
|
std::string getChunkHash(unsigned char* chunk, size_t chunk_size, unsigned hash_id);
|
||||||
int createXML(std::string filepath, size_t chunk_size, std::string xml_dir = std::string());
|
int createXML(std::string filepath, size_t chunk_size, std::string xml_dir = std::string());
|
||||||
|
@ -390,7 +390,7 @@ 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 filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename);
|
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, "extras");
|
||||||
|
|
||||||
std::string url = gogAPI->getExtraLink(games[i].gamename, games[i].extras[j].id);
|
std::string url = gogAPI->getExtraLink(games[i].gamename, games[i].extras[j].id);
|
||||||
if (gogAPI->getError())
|
if (gogAPI->getError())
|
||||||
@ -410,7 +410,7 @@ 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 filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename);
|
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, "patches");
|
||||||
|
|
||||||
std::string url = gogAPI->getPatchLink(games[i].gamename, games[i].patches[j].id);
|
std::string url = gogAPI->getPatchLink(games[i].gamename, games[i].patches[j].id);
|
||||||
if (gogAPI->getError())
|
if (gogAPI->getError())
|
||||||
@ -430,7 +430,7 @@ 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 filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename);
|
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, "languagepacks");
|
||||||
|
|
||||||
std::string url = gogAPI->getLanguagePackLink(games[i].gamename, games[i].languagepacks[j].id);
|
std::string url = gogAPI->getLanguagePackLink(games[i].gamename, games[i].languagepacks[j].id);
|
||||||
if (gogAPI->getError())
|
if (gogAPI->getError())
|
||||||
@ -520,7 +520,7 @@ void Downloader::download()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename);
|
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, "extras");
|
||||||
|
|
||||||
// Download
|
// Download
|
||||||
if (!url.empty())
|
if (!url.empty())
|
||||||
@ -553,7 +553,7 @@ void Downloader::download()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename);
|
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, "patches");
|
||||||
|
|
||||||
// Download
|
// Download
|
||||||
if (!url.empty())
|
if (!url.empty())
|
||||||
@ -586,7 +586,7 @@ void Downloader::download()
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename);
|
std::string filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, "languagepacks");
|
||||||
|
|
||||||
// Download
|
// Download
|
||||||
if (!url.empty())
|
if (!url.empty())
|
||||||
@ -1644,7 +1644,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);
|
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].extras[j].path, games[i].gamename, "extras");
|
||||||
|
|
||||||
std::string localHash = this->getLocalFileHash(filepath.string());
|
std::string localHash = this->getLocalFileHash(filepath.string());
|
||||||
size_t filesize;
|
size_t filesize;
|
||||||
@ -1665,7 +1665,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);
|
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].patches[j].path, games[i].gamename, "patches");
|
||||||
|
|
||||||
std::string localHash = this->getLocalFileHash(filepath.string());
|
std::string localHash = this->getLocalFileHash(filepath.string());
|
||||||
size_t filesize;
|
size_t filesize;
|
||||||
@ -1686,7 +1686,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);
|
boost::filesystem::path filepath = Util::makeFilepath(config.sDirectory, games[i].languagepacks[j].path, games[i].gamename, "languagepacks");
|
||||||
|
|
||||||
std::string localHash = this->getLocalFileHash(filepath.string());
|
std::string localHash = this->getLocalFileHash(filepath.string());
|
||||||
size_t filesize;
|
size_t filesize;
|
||||||
|
14
src/util.cpp
14
src/util.cpp
@ -14,7 +14,7 @@
|
|||||||
Remove the leading slash from path if needed
|
Remove the leading slash from path if needed
|
||||||
Use gamename as base directory if specified
|
Use gamename as base directory if specified
|
||||||
*/
|
*/
|
||||||
std::string Util::makeFilepath(const std::string& directory, const std::string& path, const std::string& gamename)
|
std::string Util::makeFilepath(const std::string& directory, const std::string& path, const std::string& gamename, std::string subdirectory)
|
||||||
{
|
{
|
||||||
std::string filepath;
|
std::string filepath;
|
||||||
|
|
||||||
@ -32,14 +32,12 @@ std::string Util::makeFilepath(const std::string& directory, const std::string&
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string extras = "";
|
|
||||||
if (path.find("extras")!=std::string::npos)
|
|
||||||
{
|
|
||||||
extras = "/extras";
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string filename = path.substr(path.find_last_of("/")+1, path.length());
|
std::string filename = path.substr(path.find_last_of("/")+1, path.length());
|
||||||
filepath = directory + gamename + extras + "/" + filename;
|
if (!subdirectory.empty())
|
||||||
|
{
|
||||||
|
subdirectory = "/" + subdirectory;
|
||||||
|
}
|
||||||
|
filepath = directory + gamename + subdirectory + "/" + filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
return filepath;
|
return filepath;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user