Preset subdirs (#385)

Scanning textures/presets dirs for textures and scanning preset dir for presets.
Scanning is now done recursively, so presets and textures can be organized into subdirectories instead of needing to be flattened into a single directory.

On POSIX systems makes use of [ftw](https://linux.die.net/man/3/ftw) which should be relatively efficient. Otherwise falls back to recursing with `dirent` (for windows).

Probably should have made an autoconf check for `ftw` instead of doing `#ifdef WIN32`. 

* Scan subdirectories in presets directory

* remove preset subdir config

* Recursively scan for textures too, add c++-17 compatibility

* Refactor directory scanning code so it's reused by texture loader and preset loader. Make cross-platform (maybe)

* filescanner in makefile

* extension filter for file loader

* make extensions match up'

* need string.h

* Add FileScanner.cpp to win build (maybe)

* scan all dirs

* #ifndef #ifdef is def fun

* bogus comment

* bleh

* bleh

* itunes plugin with c++17

* EyeTunes needs to know about the FileScanner

Co-authored-by: milkdropper.com <milkdropper.com@gmail.com>
Co-authored-by: milkdropper <59471060+milkdropper@users.noreply.github.com>
This commit is contained in:
Mischa Spiegelmock
2020-07-28 22:01:56 +03:00
committed by GitHub
parent e51b2c7d63
commit e49720ecfa
27 changed files with 379 additions and 330 deletions

View File

@ -81,7 +81,7 @@ void PresetFactoryManager::registerFactory(const std::string & extensions, Prese
std::unique_ptr<Preset> PresetFactoryManager::allocate(const std::string & url, const std::string & name)
{
try {
const std::string extension = parseExtension (url);
const std::string extension = "." + parseExtension(url);
return factory(extension).allocate(url, name);
} catch (const PresetFactoryException & e) {
@ -98,7 +98,7 @@ PresetFactory & PresetFactoryManager::factory(const std::string & extension) {
if (!extensionHandled(extension)) {
std::ostringstream os;
os << "No preset factory associated with \"" << extension << "\"." << std::endl;
os << "No preset factory associated with \"" << extension << "\"." << std::endl;
throw PresetFactoryException(os.str());
}
return *_factoryMap[extension];
@ -107,3 +107,11 @@ PresetFactory & PresetFactoryManager::factory(const std::string & extension) {
bool PresetFactoryManager::extensionHandled(const std::string & extension) const {
return _factoryMap.count(extension);
}
std::vector<std::string> PresetFactoryManager::extensionsHandled() const {
std::vector<std::string> retval;
for (auto const& element : _factoryMap) {
retval.push_back(element.first);
}
return retval;
}