diff options
-rw-r--r-- | src/tools/connection_patcher/Program.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/tools/connection_patcher/Program.cpp b/src/tools/connection_patcher/Program.cpp index 7321871b5ba..2179711c492 100644 --- a/src/tools/connection_patcher/Program.cpp +++ b/src/tools/connection_patcher/Program.cpp @@ -32,6 +32,8 @@ #if PLATFORM == PLATFORM_WINDOWS #include <Shlobj.h> +#elif PLATFORM == PLATFORM_UNIX +#include <pwd.h> #endif namespace po = boost::program_options; @@ -141,6 +143,7 @@ namespace Connection_Patcher ("help,h", "print usage message") ("path", po::value<std::string>()->required(), "Path to the Wow.exe") ("extra,e", po::value<uint32_t>()->implicit_value(0), "Enable patching of versions file download path. Version can be specified explicitly.") + ("modulePath,m", po::value<std::string>(), "Path to the Battle.net module download destination.") ; po::positional_options_description pos; @@ -187,11 +190,21 @@ int main(int argc, char** argv) std::string const binary_path(std::move(vm["path"].as<std::string>())); std::string renamed_binary_path(binary_path); + std::wstring appDataPath; - wchar_t* commonAppData(nullptr); #if PLATFORM == PLATFORM_WINDOWS - SHGetKnownFolderPath(FOLDERID_ProgramData, 0, NULL, &commonAppData); + wchar_t* tempPath(nullptr); + SHGetKnownFolderPath(FOLDERID_ProgramData, 0, NULL, &tempPath); + appDataPath = std::wstring(tempPath); +#elif PLATFORM == PLATFORM_UNIX + char* tempPath(nullptr); + if ((tempPath = getenv("HOME")) == nullptr) + tempPath = getpwuid(getuid())->pw_dir; + std::string tempPathStr(tempPath); + appDataPath.assign(tempPathStr.begin(), tempPathStr.end()) + std::wstring(L"/.wine/.drive_c/users/Public/Application Data"); #endif + if (vm.count("modulePath")) + appDataPath.assign(vm["modulePath"].as<std::string>().begin(), vm["modulePath"].as<std::string>().end()); std::cout << "Creating patched binary..." << std::endl; @@ -222,7 +235,7 @@ int main(int argc, char** argv) do_module<Patches::Windows::x86, Patterns::Windows::x86> ( "8f52906a2c85b416a595702251570f96d3522f39237603115f2f1ab24962043c.auth" - , std::wstring(commonAppData) + std::wstring(L"/Blizzard Entertainment/Battle.net/Cache/") + , std::wstring(appDataPath) + std::wstring(L"/Blizzard Entertainment/Battle.net/Cache/") ); break; @@ -235,7 +248,7 @@ int main(int argc, char** argv) do_module<Patches::Windows::x64, Patterns::Windows::x64> ( "0a3afee2cade3a0e8b458c4b4660104cac7fc50e2ca9bef0d708942e77f15c1d.auth" - , std::wstring(commonAppData) + std::wstring(L"/Blizzard Entertainment/Battle.net/Cache/") + , std::wstring(appDataPath) + std::wstring(L"/Blizzard Entertainment/Battle.net/Cache/") ); break; |