1
0
mirror of synced 2024-11-12 10:10:53 +01:00

sys: Allow resources to be placed in appdata on windows

This commit is contained in:
WerWolv 2021-09-13 23:55:50 +02:00
parent 222e9f6645
commit d3fb00d441
2 changed files with 38 additions and 9 deletions

View File

@ -44,7 +44,7 @@ namespace hex::plugin::builtin {
{ "hex.welcome.learn.latest.desc", "Read ImHex's current changelog" },
{ "hex.welcome.learn.latest.link", "https://github.com/WerWolv/ImHex/releases/latest" },
{ "hex.welcome.learn.pattern.title", "Pattern Language Documentation" },
{ "hex.welcome.learn.pattern.desc", "Learn how to write ImHex pattern_language with our extensive documentation" },
{ "hex.welcome.learn.pattern.desc", "Learn how to write ImHex patterns with our extensive documentation" },
{ "hex.welcome.learn.pattern.link", "https://imhex.werwolv.net/docs/pattern_language/pattern_language.html" },
{ "hex.welcome.learn.plugins.title", "Plugins API" },
{ "hex.welcome.learn.plugins.desc", "Extend ImHex with additional features using plugins" },

View File

@ -32,27 +32,56 @@ namespace hex {
CoTaskMemFree(wAppDataPath);
}
std::vector<std::filesystem::path> paths = { parentDir, appDataDir / "imhex" };
std::vector<std::string> results;
switch (path) {
case ImHexPath::Patterns:
return { (parentDir / "pattern_language").string() };
std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](auto &path){
return (path / "patterns").string();
});
break;
case ImHexPath::PatternsInclude:
return { (parentDir / "includes").string() };
std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](auto &path){
return (path / "includes").string();
});
break;
case ImHexPath::Magic:
return { (parentDir / "magic").string() };
std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](auto &path){
return (path / "magic").string();
});
break;
case ImHexPath::Python:
return { parentDir.string() };
std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](auto &path){
return (path / "python").string();
});
break;
case ImHexPath::Plugins:
return { (parentDir / "plugins").string() };
std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](auto &path){
return (path / "plugins").string();
});
break;
case ImHexPath::Yara:
return { (parentDir / "yara").string() };
std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](auto &path){
return (path / "yara").string();
});
break;
case ImHexPath::Config:
return { (appDataDir / "imhex" / "config").string() };
case ImHexPath::Resources:
return { (parentDir / "resources").string() };
std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](auto &path){
return (path / "resources").string();
});
break;
case ImHexPath::Constants:
return { (parentDir / "constants").string() };
std::transform(paths.begin(), paths.end(), std::back_inserter(results), [](auto &path){
return (path / "constants").string();
});
break;
default: __builtin_unreachable();
}
return results;
#elif defined(OS_MACOS)
return { getPathForMac(path) };
#else