realpath returns a path, not a string.
This commit is contained in:
parent
c40044feeb
commit
9812315d96
@ -927,7 +927,7 @@ SGPath SGPath::documents(const SGPath& def)
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
std::string SGPath::realpath() const
|
||||
SGPath SGPath::realpath() const
|
||||
{
|
||||
#if defined(_MSC_VER) /*for MS compilers */ || defined(_WIN32) /*needed for non MS windows compilers like MingW*/
|
||||
// with absPath NULL, will allocate, and ignore length
|
||||
@ -947,21 +947,16 @@ std::string SGPath::realpath() const
|
||||
this_dir = "/";
|
||||
}
|
||||
if (file() == "..") {
|
||||
this_dir = SGPath(SGPath(this_dir).realpath()).dir();
|
||||
this_dir = SGPath(this_dir).realpath().dir();
|
||||
if (this_dir.empty()) { // invalid path: .. above root
|
||||
return "";
|
||||
return SGPath();
|
||||
}
|
||||
return SGPath(this_dir).realpath(); // use native path separator,
|
||||
// and handle 'existing/nonexisting/../symlink' paths
|
||||
}
|
||||
return SGPath(this_dir).realpath() +
|
||||
#if defined(_MSC_VER) || defined(_WIN32)
|
||||
"\\" + file();
|
||||
#else
|
||||
"/" + file();
|
||||
#endif
|
||||
return SGPath(this_dir).realpath() / file();
|
||||
}
|
||||
std::string p(buf);
|
||||
SGPath p(SGPath::fromLocal8Bit(buf));
|
||||
free(buf);
|
||||
return p;
|
||||
}
|
||||
|
@ -131,10 +131,10 @@ public:
|
||||
void concat( const std::string& p );
|
||||
|
||||
/**
|
||||
* Returns a string with the absolute pathname that names the same file, whose
|
||||
* Returns a path with the absolute pathname that names the same file, whose
|
||||
* resolution does not involve '.', '..', or symbolic links.
|
||||
*/
|
||||
std::string realpath() const;
|
||||
SGPath realpath() const;
|
||||
|
||||
/**
|
||||
* Get the file part of the path (everything after the last path sep)
|
||||
|
Loading…
Reference in New Issue
Block a user