Skip to content

Commit be2a05b

Browse files
committed
Add support for copying symlinks in Plugin Installer
1 parent 9a667c9 commit be2a05b

2 files changed

Lines changed: 17 additions & 16 deletions

File tree

Source/Processors/PluginManager/PluginManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ bool PluginManager::removePlugin(String libName)
565565
}
566566

567567
if(indexToRemove == -1)
568-
return false;
568+
return true;
569569

570570
LoadedLibInfo lib = libArray[indexToRemove];
571571

Source/UI/PluginInstaller.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include "PluginInstaller.h"
2525
#include <stdio.h>
26+
#include <filesystem>
2627

2728
#include "../CoreServices.h"
2829
#include "../AccessClass.h"
@@ -1517,24 +1518,24 @@ int PluginInfoComponent::downloadPlugin(const String& plugin, const String& vers
15171518
}
15181519
}
15191520

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();
15221526

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-
}
15301527

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+
;
15331532

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+
}
15381539

15391540
tempDir.deleteRecursively();
15401541
pluginFile.deleteFile(); // delete zip after uncompressing

0 commit comments

Comments
 (0)