Parses a filename into four useful pieces.
844 std::string f = filename;
857 if ((f.size() >= 2) && (f[1] ==
':')) {
859 if ((f.size() > 2) &&
isSlash(f[2])) {
862 root = f.substr(0, 3);
863 f = f.substr(3, f.size() - 3);
869 f = f.substr(2, f.size() - 2);
876 root = f.substr(0, 2);
877 f = f.substr(2, f.size() - 2);
881 root = f.substr(0, 1);
882 f = f.substr(1, f.size() - 1);
889 size_t i = f.rfind(
'.');
891 if (i != std::string::npos) {
894 if ((j == std::string::npos) || (i > j)) {
895 ext = f.substr(i + 1, f.size() - i - 1);
906 if (i == std::string::npos) {
912 }
else if ((i != std::string::npos) && (i < f.size() - 1)) {
914 base = f.substr(i + 1, f.size() - i - 1);
921 size_t prev, cur = 0;
923 while (cur < f.size()) {
927 size_t i = f.find(
'/', prev + 1);
928 size_t j = f.find(
'\\', prev + 1);
929 if (i == std::string::npos) {
933 if (j == std::string::npos) {
939 if (cur == std::string::npos) {
943 path.
append(f.substr(prev, cur - prev));
size_t findLastSlash(const std::string &f, size_t start=std::string::npos)
Definition: stringutils.h:58
T min(const T &x, const T &y)
Definition: g3dmath.h:305
bool isSlash(const unsigned char c)
Definition: stringutils.h:175
static std::string ext(const std::string &path)
Definition: FileSystem.cpp:755
void clear(bool shrink=true)
Definition: Array.h:407
static std::string base(const std::string &path)
Definition: FileSystem.cpp:783
int prev(int i, int n)
Definition: RecastContour.cpp:468
void append(const T &value)
Definition: Array.h:583