@@ -366,15 +366,20 @@ class ISystem : public core::IReferenceCounted
366
366
367
367
bool createDirectory (const system::path& p)
368
368
{
369
- return std::filesystem::create_directory (p);
369
+ return std::filesystem::create_directories (p);
370
370
}
371
371
372
372
bool deleteDirectory (const system::path& p)
373
373
{
374
374
return std::filesystem::remove (p);
375
375
}
376
376
377
-
377
+ bool moveFileOrDirectory (const system::path oldPath, const system::path newPath)
378
+ {
379
+ std::error_code ec;
380
+ std::filesystem::rename (oldPath, newPath, ec);
381
+ return static_cast <bool >(ec);
382
+ }
378
383
/*
379
384
Recursively lists all files and directories in the directory.
380
385
*/
@@ -431,22 +436,19 @@ class ISystem : public core::IReferenceCounted
431
436
*/
432
437
bool copy (const system::path& from, const system::path& to)
433
438
{
434
- constexpr auto copyFile = [this ](const system::path& from, const system::path& to)
439
+ auto copyFile = [this ](const system::path& from, const system::path& to)
435
440
{
436
- system::future<core::smart_refctd_ptr<IFile>> readFileFut, writeFileFut;
437
- system::future<size_t > readFut, writeFut;
441
+ future_t <core::smart_refctd_ptr<IFile>> readFileFut, writeFileFut;
438
442
439
443
createFile (readFileFut, from, IFile::ECF_READ);
440
- createFile (writeFileFut, from , IFile::ECF_WRITE);
441
- auto readFile = readFileFut.get ();
442
- auto writeFile = writeFileFut.get ();
444
+ createFile (writeFileFut, to , IFile::ECF_WRITE);
445
+ auto readF = readFileFut.get ();
446
+ auto writeF = writeFileFut.get ();
443
447
444
- char * fileData = (char *)malloc (readFile->getSize ());
445
- readFile->read (readFut, fileData, 0 , readFile->getSize ());
446
- readFut.get ();
448
+ char * fileData = (char *)malloc (readF->getSize ());
449
+ readF->read_impl (fileData, 0 , readF->getSize ());
447
450
448
- writeFile->write (writeFut, fileData, 0 , readFile->getSize ());
449
- writeFut.get ();
451
+ writeF->write_impl (fileData, 0 , readF->getSize ());
450
452
451
453
free (fileData);
452
454
};
@@ -459,8 +461,12 @@ class ISystem : public core::IReferenceCounted
459
461
for (const auto & file : allFiles)
460
462
{
461
463
auto relative = std::filesystem::relative (file, from);
462
- auto targetName = to / relative;
463
- copyFile (file, targetName);
464
+ system::path targetName = (to / relative).generic_string ();
465
+ std::filesystem::create_directories (targetName.parent_path ());
466
+ if (!isDirectory (targetName))
467
+ {
468
+ copyFile (file, targetName);
469
+ }
464
470
}
465
471
}
466
472
else
0 commit comments