|
23 | 23 |
|
24 | 24 | #include "PluginInstaller.h" |
25 | 25 | #include <stdio.h> |
| 26 | +#include <filesystem> |
26 | 27 |
|
27 | 28 | #include "../CoreServices.h" |
28 | 29 | #include "../AccessClass.h" |
@@ -1517,24 +1518,24 @@ int PluginInfoComponent::downloadPlugin(const String& plugin, const String& vers |
1517 | 1518 | } |
1518 | 1519 | } |
1519 | 1520 |
|
1520 | | - // copy shared files |
1521 | | - Array<File> sFiles = tempDir.getChildFile("shared").findChildFiles(File::findFilesAndDirectories, false); |
| 1521 | + /* Copy shared files |
| 1522 | + * Uses C++17's filesystem::copy functionality to allow copying symlinks |
| 1523 | + */ |
| 1524 | + std::filesystem::path tempSharedPath = tempDir.getChildFile("shared").getFullPathName().toStdString(); |
| 1525 | + std::filesystem::path destSharedPath = getSharedDirectory().getFullPathName().toStdString(); |
1522 | 1526 |
|
1523 | | - for(int i = 0; i < sFiles.size() ; i++) |
1524 | | - { |
1525 | | - if(sFiles[i].isDirectory()) |
1526 | | - sFiles[i].copyDirectoryTo(getSharedDirectory().getChildFile(sFiles[i].getFileName())); |
1527 | | - else |
1528 | | - sFiles[i].copyFileTo(getSharedDirectory().getChildFile(sFiles[i].getFileName())); |
1529 | | - } |
1530 | 1527 |
|
1531 | | - // copy any extra files |
1532 | | - Array<File> extraFiles = tempDir.findChildFiles(File::findFiles, false); |
| 1528 | + const auto copyOptions = std::filesystem::copy_options::overwrite_existing |
| 1529 | + | std::filesystem::copy_options::recursive |
| 1530 | + | std::filesystem::copy_options::copy_symlinks |
| 1531 | + ; |
1533 | 1532 |
|
1534 | | - for(int j = 0; j < extraFiles.size() ; j++) |
1535 | | - { |
1536 | | - extraFiles[j].copyFileTo(CoreServices::getSavedStateDirectory().getChildFile(extraFiles[j].getFileName())); |
1537 | | - } |
| 1533 | + |
| 1534 | + try { |
| 1535 | + std::filesystem::copy(tempSharedPath, destSharedPath, copyOptions); |
| 1536 | + } catch(std::filesystem::filesystem_error& e) { |
| 1537 | + LOGE("Could not copy shared files: \"", e.what(), "\""); |
| 1538 | + } |
1538 | 1539 |
|
1539 | 1540 | tempDir.deleteRecursively(); |
1540 | 1541 | pluginFile.deleteFile(); // delete zip after uncompressing |
|
0 commit comments