X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Floader%2Futility.cpp;fp=src%2Floader%2Futility.cpp;h=ee88ea0d0dc880a20126d38c87a81085c08a6b4c;hb=f3230836ca2e263e84b58ffec6645c0f77439117;hp=0000000000000000000000000000000000000000;hpb=771a3daeecf527a9b5873e412e263ad251c59ab5;p=l2e.git diff --git a/src/loader/utility.cpp b/src/loader/utility.cpp new file mode 100644 index 0000000..ee88ea0 --- /dev/null +++ b/src/loader/utility.cpp @@ -0,0 +1,41 @@ +/* + * utility.cpp + * + * Created on: Sep 1, 2012 + * Author: holy + */ + +#include "utility.h" + +#include +#include + +using std::string; + +namespace loader { + +string Dirname(const string &path) { + // unix version + char *str(new char[path.size() + 1]); + std::memcpy(str, path.c_str(), path.size()); + str[path.size()] = '\0'; + string dn(dirname(str)); + delete str; + return dn; +} + +string CatPath(const string &lhs, const string &rhs) { + // unix version + string path(lhs); + if (!path.empty() && path[path.size() - 1] != '/') { + path += '/'; + } + if (!rhs.empty() && rhs[0] == '/') { + path.append(rhs, 1, string::npos); + } else { + path += rhs; + } + return path; +} + +}