Use generic_string() in a couple of places to avoid unwanted backslashes in filenames.
authorCarl Hetherington <cth@carlh.net>
Mon, 18 Apr 2016 21:15:10 +0000 (22:15 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 18 Apr 2016 21:15:10 +0000 (22:15 +0100)
ChangeLog
src/lib/curl_uploader.cc
src/lib/scp_uploader.cc

index 3ff75fc8d8f33372f286d47ec50653138a9bf7c7..a4d7ccc5b6626c8a0b909f344648fbadb723d168 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-04-18  Carl Hetherington  <cth@carlh.net>
+
+       * Possibly fix strange paths when uploading DCPs using
+       FTP/SCP.
+
 2016-04-17  Carl Hetherington  <cth@carlh.net>
 
        * Updated nl_NL translation from Rob van Nieuwkerk.
index 11c389307b43fca1b5b86c7fad9522d824040632..48f98248250f9b03fd1f61df5c4cb90c087da21d 100644 (file)
@@ -76,7 +76,8 @@ CurlUploader::upload_file (boost::filesystem::path from, boost::filesystem::path
 {
        curl_easy_setopt (
                _curl, CURLOPT_URL,
-               String::compose ("ftp://%1/%2/%3", Config::instance()->tms_ip(), Config::instance()->tms_path(), to.string ()).c_str ()
+               /* Use generic_string so that we get forward-slashes in the path, even on Windows */
+               String::compose ("ftp://%1/%2/%3", Config::instance()->tms_ip(), Config::instance()->tms_path(), to.generic_string ()).c_str ()
                );
 
        _file = fopen_boost (from, "rb");
index 18ace439bab012ba5eba2b67b4a4d2f49393a84c..603d53cdf6731699a256d4d776eba11eab0a69bb 100644 (file)
@@ -81,7 +81,8 @@ SCPUploader::~SCPUploader ()
 void
 SCPUploader::create_directory (boost::filesystem::path directory)
 {
-       int const r = ssh_scp_push_directory (_scp, directory.string().c_str(), S_IRWXU);
+       /* Use generic_string so that we get forward-slashes in the path, even on Windows */
+       int const r = ssh_scp_push_directory (_scp, directory.generic_string().c_str(), S_IRWXU);
        if (r != SSH_OK) {
                throw NetworkError (String::compose (_("Could not create remote directory %1 (%2)"), directory, ssh_get_error (_session)));
        }
@@ -91,7 +92,8 @@ void
 SCPUploader::upload_file (boost::filesystem::path from, boost::filesystem::path to, boost::uintmax_t& transferred, boost::uintmax_t total_size)
 {
        boost::uintmax_t to_do = boost::filesystem::file_size (from);
-       ssh_scp_push_file (_scp, to.string().c_str(), to_do, S_IRUSR | S_IWUSR);
+       /* Use generic_string so that we get forward-slashes in the path, even on Windows */
+       ssh_scp_push_file (_scp, to.generic_string().c_str(), to_do, S_IRUSR | S_IWUSR);
 
        FILE* f = fopen_boost (from, "rb");
        if (f == 0) {