38 lines
987 B
C++
38 lines
987 B
C++
#include "files.h"
|
|
|
|
void mrbesen::Files::parent(const std::string& child, std::string& out) {
|
|
//letzten path trenner finden
|
|
size_t pos = child.rfind('/', child.length() -2); //das erste Zeichen überspringen (könnte ein / sein)
|
|
if(pos == std::string::npos)
|
|
pos = child.rfind('\\');
|
|
if(pos != std::string::npos)
|
|
out = child.substr(0, pos+1);
|
|
else
|
|
out = "";
|
|
}
|
|
|
|
void mrbesen::Files::file(const std::string& path, std::string& out) {
|
|
//letzten path trenner finden
|
|
size_t pos = path.rfind('/', path.length() -2); //das erste Zeichen überspringen (könnte ein / sein)
|
|
if(pos == std::string::npos)
|
|
pos = path.rfind('\\');
|
|
if(pos != std::string::npos)
|
|
out = path.substr(pos+1);
|
|
else
|
|
out = path;
|
|
}
|
|
|
|
void mrbesen::Files::extention(const std::string& path, std::string& ext) {
|
|
std::string filestr;
|
|
file(path, filestr);
|
|
size_t pos = filestr.rfind('.');
|
|
|
|
if(pos == std::string::npos || pos+1 == filestr.size()) {
|
|
ext = "";
|
|
return;
|
|
}
|
|
|
|
ext = filestr.substr(pos+1);
|
|
}
|
|
|