2011-10-02 10:05:45 +00:00
|
|
|
#ifdef NALL_STRING_INTERNAL_HPP
|
2010-10-14 10:07:38 +00:00
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
2011-03-17 10:20:51 +00:00
|
|
|
string currentpath() {
|
2010-10-14 10:07:38 +00:00
|
|
|
char path[PATH_MAX];
|
2011-03-17 10:20:51 +00:00
|
|
|
if(::getcwd(path)) {
|
2010-10-14 10:07:38 +00:00
|
|
|
string result(path);
|
|
|
|
result.transform("\\", "/");
|
2011-03-17 10:20:51 +00:00
|
|
|
if(result.endswith("/") == false) result.append("/");
|
2010-10-14 10:07:38 +00:00
|
|
|
return result;
|
|
|
|
}
|
2011-03-17 10:20:51 +00:00
|
|
|
return "./";
|
2010-10-14 10:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
string userpath() {
|
|
|
|
char path[PATH_MAX];
|
|
|
|
if(::userpath(path)) {
|
|
|
|
string result(path);
|
|
|
|
result.transform("\\", "/");
|
|
|
|
if(result.endswith("/") == false) result.append("/");
|
|
|
|
return result;
|
|
|
|
}
|
2011-03-17 10:20:51 +00:00
|
|
|
return currentpath();
|
2010-10-14 10:07:38 +00:00
|
|
|
}
|
|
|
|
|
2011-03-17 10:20:51 +00:00
|
|
|
string realpath(const char *name) {
|
2010-10-14 10:07:38 +00:00
|
|
|
char path[PATH_MAX];
|
2011-03-17 10:20:51 +00:00
|
|
|
if(::realpath(name, path)) {
|
2010-10-14 10:07:38 +00:00
|
|
|
string result(path);
|
|
|
|
result.transform("\\", "/");
|
|
|
|
return result;
|
|
|
|
}
|
2011-03-17 10:20:51 +00:00
|
|
|
return userpath();
|
2010-10-14 10:07:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|