From e92c7f29483de3f63599c8836eb69dd315d67917 Mon Sep 17 00:00:00 2001 From: "cedric.riou" <cedric.riou@inria.fr> Date: Mon, 9 Apr 2018 09:52:29 +0200 Subject: [PATCH] [module] manage old boost version for copy operations --- modules/fs/src/Files.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/fs/src/Files.cpp b/modules/fs/src/Files.cpp index b20b8b17a..b93d3813b 100644 --- a/modules/fs/src/Files.cpp +++ b/modules/fs/src/Files.cpp @@ -462,8 +462,8 @@ bool Files::removeAll(const char* path) -// Due to Ubuntu 14.0 compliance, BOOST could not be available -// manage all cases here +// old boost compliance +// manage cases here #if defined TARGET_HAS_Boost && BOOST_VERSION / 100 % 1000 >= 55 @@ -506,7 +506,7 @@ bool Files::copyDirectory(const char* sourceDir, const char* targetDir) #error OpenViBE requires at least boost 1.55 to compile on Windows #else -// hugly hack in case of no boost on linux ... +// ugly hack for old boost on linux ... bool Files::copyFile(const char* sSourceFile, const char* sDestinationPath) { if(!sSourceFile || !sDestinationPath) @@ -514,7 +514,12 @@ bool Files::copyFile(const char* sSourceFile, const char* sDestinationPath) return false; } - std::string command = std::string("cp ") + sSourceFile + " " + sDestinationPath; + if (FS::Files::fileExists(sDestinationPath)) + { + return false; + } + + std::string command = std::string("cp '") + sSourceFile + "' '" + sDestinationPath+"'"; return (std::system(command.c_str()) != -1); } @@ -527,7 +532,12 @@ bool Files::copyDirectory(const char* sourceDir, const char* targetDir) return false; } - std::string command = std::string("cp -r ") + sourceDir + " " + targetDir+""; + if (FS::Files::directoryExists(targetDir)) + { + return false; + } + + std::string command = std::string("cp -r '") + sourceDir + "' '" + targetDir+"'"; return (std::system(command.c_str()) != -1); } #endif -- GitLab