From 4c7a2729d5d5e1ed7b782ad292230f3c546f7725 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Fri, 27 May 2011 16:39:01 +0000 Subject: [PATCH] - bugfix for windows users 7z extraction --- .../include/platform/common/platform_common.h | 2 +- .../platform/common/platform_common.cpp | 25 ++++++++++++++----- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index a269958a3..9f9ed1a5f 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -165,7 +165,7 @@ void restoreVideoMode(bool exitingApp=false); bool StartsWith(const std::string &str, const std::string &key); bool EndsWith(const string &str, const string& key); -void endPathWithSlash(string &path); +void endPathWithSlash(string &path, bool requireOSSlash=false); void trimPathWithStartingSlash(string &path); void updatePathClimbingParts(string &path); diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index 1b13a7695..e097d2d41 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -469,13 +469,15 @@ bool EndsWith(const string &str, const string& key) return result; } -void endPathWithSlash(string &path) { +void endPathWithSlash(string &path,bool requireOSSlash) { if(EndsWith(path, "/") == false && EndsWith(path, "\\") == false) { + string seperator = "/"; + if(requireOSSlash == true) { #if defined(WIN32) - path += "\\"; -#else - path += "/"; + seperator = "\\"; #endif + } + path += seperator; } } @@ -1663,10 +1665,21 @@ string replaceAll(string& context, const string& from, const string& to) { string getFullFileArchiveExtractCommand(string fileArchiveExtractCommand, string fileArchiveExtractCommandParameters, string outputpath, string archivename) { + string parsedOutputpath = outputpath; + string parsedArchivename = archivename; + +// This is required for execution on win32 +#if defined(WIN32) + replaceAll(parsedOutputpath, "\\\\", "\\"); + replaceAll(parsedOutputpath, "/", "\\"); + replaceAll(parsedArchivename, "\\\\", "\\"); + replaceAll(parsedArchivename, "/", "\\"); +#endif + string result = fileArchiveExtractCommand; result += " "; - string args = replaceAll(fileArchiveExtractCommandParameters, "{outputpath}", outputpath); - args = replaceAll(args, "{archivename}", archivename); + string args = replaceAll(fileArchiveExtractCommandParameters, "{outputpath}", parsedOutputpath); + args = replaceAll(args, "{archivename}", parsedArchivename); result += args; return result;