| @@ -24,10 +24,6 @@ std::string join(const std::string& path1, const std::string& path2, Paths... pa | |||||
| `depth` is the number of directories to recurse. 0 depth does not recurse. -1 depth recurses infinitely. | `depth` is the number of directories to recurse. 0 depth does not recurse. -1 depth recurses infinitely. | ||||
| */ | */ | ||||
| std::vector<std::string> getEntries(const std::string& dirPath, int depth = 0); | std::vector<std::string> getEntries(const std::string& dirPath, int depth = 0); | ||||
| /** Expands a glob pattern such as `dir/file*.txt` to a list of paths. | |||||
| Paths are sorted. | |||||
| */ | |||||
| std::vector<std::string> glob(const std::string& pattern); | |||||
| bool exists(const std::string& path); | bool exists(const std::string& path); | ||||
| /** Returns whether the given path is a file. */ | /** Returns whether the given path is a file. */ | ||||
| bool isFile(const std::string& path); | bool isFile(const std::string& path); | ||||
| @@ -4,6 +4,7 @@ | |||||
| #include <map> | #include <map> | ||||
| #include <stdexcept> | #include <stdexcept> | ||||
| #include <tuple> | #include <tuple> | ||||
| #include <regex> | |||||
| #include <sys/types.h> | #include <sys/types.h> | ||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||
| @@ -244,6 +245,15 @@ static void extractPackages(std::string path) { | |||||
| } | } | ||||
| } | } | ||||
| static std::string getFundamentalPackagePath() { | |||||
| std::regex r("Fundamental-.*-" + APP_OS + "-" + APP_CPU + "\\.vcvplugin"); | |||||
| for (const std::string& path : system::getEntries(asset::systemDir)) { | |||||
| if (std::regex_match(system::getFilename(path), r)) | |||||
| return path; | |||||
| } | |||||
| return ""; | |||||
| } | |||||
| //////////////////// | //////////////////// | ||||
| // public API | // public API | ||||
| //////////////////// | //////////////////// | ||||
| @@ -284,7 +294,7 @@ void init() { | |||||
| // If Fundamental wasn't loaded, copy the bundled Fundamental package and load it | // If Fundamental wasn't loaded, copy the bundled Fundamental package and load it | ||||
| if (!settings::devMode && !getPlugin("Fundamental")) { | if (!settings::devMode && !getPlugin("Fundamental")) { | ||||
| std::string fundamentalPackage = get(system::glob(asset::system("Fundamental-*-" + APP_OS + "-" + APP_CPU + ".vcvplugin")), 0); | |||||
| std::string fundamentalPackage = getFundamentalPackagePath(); | |||||
| std::string fundamentalDir = system::join(pluginsPath, "Fundamental"); | std::string fundamentalDir = system::join(pluginsPath, "Fundamental"); | ||||
| if (fundamentalPackage != "" && system::isFile(fundamentalPackage)) { | if (fundamentalPackage != "" && system::isFile(fundamentalPackage)) { | ||||
| INFO("Extracting bundled Fundamental package"); | INFO("Extracting bundled Fundamental package"); | ||||
| @@ -9,7 +9,6 @@ | |||||
| #include <dirent.h> | #include <dirent.h> | ||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||
| #include <cxxabi.h> // for abi::__cxa_demangle | #include <cxxabi.h> // for abi::__cxa_demangle | ||||
| #include <glob.h> | |||||
| #if defined ARCH_LIN || defined ARCH_MAC | #if defined ARCH_LIN || defined ARCH_MAC | ||||
| #include <pthread.h> | #include <pthread.h> | ||||
| @@ -89,22 +88,6 @@ std::vector<std::string> getEntries(const std::string& dirPath, int depth) { | |||||
| } | } | ||||
| std::vector<std::string> glob(const std::string& pattern) { | |||||
| glob_t glob_result; | |||||
| memset(&glob_result, 0, sizeof(glob_result)); | |||||
| std::vector<std::string> paths; | |||||
| if (!glob(pattern.c_str(), GLOB_BRACE, NULL, &glob_result)) { | |||||
| for (size_t i = 0; i < glob_result.gl_pathc; i++) { | |||||
| paths.push_back(std::string(glob_result.gl_pathv[i])); | |||||
| } | |||||
| } | |||||
| globfree(&glob_result); | |||||
| return paths; | |||||
| } | |||||
| bool exists(const std::string& path) { | bool exists(const std::string& path) { | ||||
| try { | try { | ||||
| return fs::exists(fs::u8path(path)); | return fs::exists(fs::u8path(path)); | ||||