]> git.localhorst.tv Git - l2e.git/blob - src/loader/utility.cpp
removed stupid file headers that eclipse put in
[l2e.git] / src / loader / utility.cpp
1 #include "utility.h"
2
3 #include <cstring>
4 #include <libgen.h>
5
6 using std::string;
7
8 namespace loader {
9
10 string Dirname(const string &path) {
11         char *str(new char[path.size() + 1]);
12         std::memcpy(str, path.c_str(), path.size());
13         str[path.size()] = '\0';
14         string dn(dirname(str));
15         delete[] str;
16         return dn;
17 }
18
19 string CatPath(const string &lhs, const string &rhs) {
20         string path(lhs);
21         if (!path.empty()
22                         && path[path.size() - 1] != '/'
23                         && path[path.size() - 1] != '\\') {
24                 path += '/';
25         }
26         if (!rhs.empty() && (rhs[0] == '/' || rhs[0] == '\\')) {
27                 path.append(rhs, 1, string::npos);
28         } else {
29                 path += rhs;
30         }
31         return path;
32 }
33
34 }