1#include <Core/Resources/Resources.hpp>
2#include <Core/Utils/StdOptional.hpp>
3#include <cpplocate/cpplocate.h>
13using namespace Ra::Core::Utils;
14namespace fs = ::std::filesystem;
20 std::string p = cpplocate::locatePath( pattern, system, libSymbol );
21 return fs::path( p ).lexically_normal();
25fs::path clean(
const fs::path& path ) {
26 auto status = fs::status( path );
27 if ( status.type() == fs::file_type::not_found )
return "";
28 if ( status.type() == fs::file_type::directory )
return fs::canonical( path ) /
"";
29 return fs::canonical( path );
36 p = clean( p /
"Resources/Radium" );
38 if ( p.empty() )
return {};
44 p = clean( p /
"Plugins" /
"lib" );
46 if ( p.empty() )
return {};
52 return clean( cpplocate::getModulePath() ).string();
56 auto p = searchPath( pattern,
"", symbol );
57 p = clean( p / pattern );
58 if ( p.empty() )
return {};
69 if ( DataPath::s_dataPaths.empty() ) {
return fs::current_path().string(); }
70 return DataPath::s_dataPaths.top();
74 if ( DataPath::s_dataPaths.empty() ) {
return fs::current_path().string(); }
75 auto p = DataPath::s_dataPaths.top();
76 DataPath::s_dataPaths.pop();
81 DataPath::s_dataPaths.emplace(
std::move( datapath ) );
82 fs::create_directories( DataPath::s_dataPaths.top() );
11namespace Resources {
…}
std::string getDataPath()
Get the current data path.
std::string popDataPath()
Pop the current data path.
optional< std::string > getRadiumPluginsPath()
Get the path of Radium embedded plugins.
optional< std::string > getBasePath()
this one is always found, use optional for consistency ?
void pushDataPath(std::string datapath)
Push a new data path.
optional< std::string > getResourcesPath(void *symbol, const std::string &pattern)
Search for general resource path.
optional< std::string > getRadiumResourcesPath()
Get the path of Radium internal resources.
hepler function to manage enum as underlying types in VariableSet