Program Listing for File strpath_manip.hpp¶
↰ Return to documentation for file (/home/runner/work/Legion-Engine/Legion-Engine/legion/engine/core/filesystem/detail/strpath_manip.hpp
)
#pragma once
#include <string>
#include <core/platform/platform.hpp>
#define SEP_WINDOWS 1
#define SEP_NIX 2
#ifdef _WIN32
#define OSSEP SEP_WINDOWS
#else
#define OSSEP SEP_NIX
#endif
namespace legion::core::filesystem
{
class strpath_manip
{
public:
static std::string parent(const std::string& p);
static std::string subdir(const std::string& p, const std::string& sub);
static std::string sanitize(const std::string& p, bool fail_on_fs_leave = false);
static std::string localize(const std::string& p);
static std::string& inline_localize(std::string& p);
constexpr static char separator()
{
if constexpr (OSSEP == SEP_WINDOWS)
return '\\';
else return '/';
}
private:
constexpr static char anti_separator()
{
if constexpr (OSSEP == SEP_NIX)
return '\\';
else return '/';
}
};
}
#undef OSSEP
#undef SEP_NIX
#undef SEP_WINDOWS