MCPcopy Create free account
hub / github.com/city-super/Octree-GS / copyFile

Function copyFile

SIBR_viewers/src/core/system/Utils.cpp:247–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

245 }
246
247 bool copyFile(const std::string & src, const std::string & dst, const bool overwrite)
248 {
249 boost::filesystem::path source = src;
250 boost::filesystem::path destination = dst;
251 namespace fs = boost::filesystem;
252 try {
253 // Check whether the function call is valid
254 if (!fs::exists(source) || !fs::is_regular_file(source))
255 {
256 std::cerr << "Source file " << source.string()
257 << " does not exist or is not a regular file." << '\n'
258 ;
259 return false;
260 }
261
262 // If the destination is a directory, we copy the file into this directory, with the same name.
263 if (fs::is_directory(destination)) {
264 destination = destination / source.filename();
265 }
266
267 if (fs::exists(destination) && !overwrite)
268 {
269 std::cerr << "Destination file " << destination.string()
270 << " already exists." << '\n'
271 ;
272 return false;
273 }
274 if(overwrite) {
275 fs::copy_file(source, destination, boost::filesystem::copy_option::overwrite_if_exists);
276 } else {
277 fs::copy_file(source, destination);
278 }
279
280 }
281 catch (fs::filesystem_error const & e)
282 {
283 std::cerr << e.what() << '\n';
284 return false;
285 }
286
287 return true;
288 }
289
290 void emptyDirectory(const std::string& path) {
291 boost::filesystem::path p(path);

Callers 2

mainFunction · 0.85
mainFunction · 0.85

Calls 2

whatMethod · 0.80
stringMethod · 0.45

Tested by

no test coverage detected