From d73cf769f1b404b899f32d0af1ea5ab68654fa69 Mon Sep 17 00:00:00 2001 From: Arvid Norberg Date: Sun, 7 Mar 2010 21:59:02 +0000 Subject: [PATCH] weird ubuntu std::string bug work-around --- src/file.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/file.cpp b/src/file.cpp index 33981c766..7bf21ef11 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -444,12 +444,18 @@ namespace libtorrent if (rhs.empty()) return lhs; #ifdef TORRENT_WINDOWS +#define TORRENT_SEPARATOR "\\" bool need_sep = lhs[lhs.size()-1] != '\\' && lhs[lhs.size()-1] != '/'; - return lhs + (need_sep?"\\":"") + rhs; #else +#define TORRENT_SEPARATOR "/" bool need_sep = lhs[lhs.size()-1] != '/'; - return lhs + (need_sep?"/":"") + rhs; #endif + std::string ret; + int target_size = lhs.size() + rhs.size() + 2; + ret.resize(target_size); + snprintf(&ret[0], target_size, "%s%s%s", lhs.c_str() + , (need_sep?TORRENT_SEPARATOR:""), rhs.c_str()); + return ret; } std::string current_working_directory()