some small refactorings
This commit is contained in:
parent
d8fac9045b
commit
8eda3df225
23 changed files with 314 additions and 268 deletions
|
@ -34,12 +34,20 @@ public:
|
|||
static path& get();
|
||||
~path();
|
||||
|
||||
std::string separator();
|
||||
std::string separator() const;
|
||||
|
||||
std::string executable_path();
|
||||
std::string executable_path() const;
|
||||
|
||||
std::string resource_path() const;
|
||||
|
||||
typedef std::vector<std::string> path_list;
|
||||
|
||||
std::string find_file(const std::string &filename) const;
|
||||
|
||||
path_list resource_paths() const { return _resource_paths; }
|
||||
|
||||
std::string get_filename(const std::string &filepath, bool with_extension = true) const;
|
||||
|
||||
protected:
|
||||
|
||||
path_list _plugin_paths;
|
||||
|
|
|
@ -18,6 +18,9 @@
|
|||
// Unknown platform
|
||||
#endif
|
||||
|
||||
// Why? LLVM does not adhere to C++17
|
||||
//#include <filesystem>
|
||||
|
||||
namespace pw {
|
||||
|
||||
|
||||
|
@ -44,7 +47,7 @@ path::~path()
|
|||
{
|
||||
}
|
||||
|
||||
std::string path::separator()
|
||||
std::string path::separator() const
|
||||
{
|
||||
#if defined(WIN32)
|
||||
return std::string("\\");
|
||||
|
@ -53,7 +56,7 @@ std::string path::separator()
|
|||
#endif
|
||||
}
|
||||
|
||||
std::string path::executable_path()
|
||||
std::string path::executable_path() const
|
||||
{
|
||||
std::string result;
|
||||
const size_t MAXPATHLEN = 2048;
|
||||
|
@ -81,9 +84,27 @@ std::string path::executable_path()
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string path::find_file(const std::string& filename) const
|
||||
{
|
||||
// for ()
|
||||
}
|
||||
|
||||
path::path()
|
||||
{
|
||||
_impl = std::make_unique<impl>(*this);
|
||||
}
|
||||
|
||||
std::string path::get_filename(const std::string& filepath,
|
||||
bool with_extension) const
|
||||
{
|
||||
std::size_t dotPos = filepath.rfind('.');
|
||||
std::size_t sepPos = filepath.rfind(separator());
|
||||
|
||||
if(sepPos != std::string::npos) {
|
||||
return filepath.substr(sepPos + 1,
|
||||
filepath.size() - (with_extension || dotPos != std::string::npos ? 1 : dotPos) );
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue