MCPcopy Create free account
hub / github.com/comaps/comaps / CopyFileX

Function CopyFileX

libs/coding/internal/file_data.cpp:267–299  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

265}
266
267bool CopyFileX(string const & fOld, string const & fNew)
268{
269 ifstream ifs;
270 ofstream ofs;
271 ifs.exceptions(ifstream::failbit | ifstream::badbit);
272 ofs.exceptions(ifstream::failbit | ifstream::badbit);
273
274 try
275 {
276 ifs.open(fOld.c_str());
277 ofs.open(fNew.c_str());
278
279 // If source file is empty - make empty dest file without any errors.
280 if (IsEOF(ifs))
281 return true;
282
283 ofs << ifs.rdbuf();
284 ofs.flush();
285 return true;
286 }
287 catch (system_error const &)
288 {
289 LOG(LWARNING, ("Failed to copy file from", fOld, "to", fNew, ":", strerror(errno)));
290 }
291 catch (exception const &)
292 {
293 LOG(LERROR, ("Unknown error when coping files:", fOld, "to", fNew, strerror(errno)));
294 }
295
296 // Don't care about possible error here ..
297 (void)DeleteFileX(fNew);
298 return false;
299}
300
301bool IsEqualFiles(string const & firstFile, string const & secondFile)
302{

Callers 10

SaveMethod · 0.85
SaveMethod · 0.85
SaveMethod · 0.85
SaveMethod · 0.85
UNIT_TESTFunction · 0.85
MoveFileXFunction · 0.85
UNIT_TESTFunction · 0.85
UNIT_CLASS_TESTFunction · 0.85

Calls 3

IsEOFFunction · 0.85
DeleteFileXFunction · 0.85
openMethod · 0.80

Tested by 3

UNIT_TESTFunction · 0.68
UNIT_TESTFunction · 0.68
UNIT_CLASS_TESTFunction · 0.68