#199: ADd method to return the absolute (real) path.
This commit is contained in:
parent
7ee2633164
commit
cee8c5b5c7
@ -483,3 +483,16 @@ bool SGPath::rename(const SGPath& newName)
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string SGPath::realpath() const
|
||||
{
|
||||
#ifdef _WIN32
|
||||
// Not implemented for Windows yet. Return original path instead.
|
||||
return path;
|
||||
#else
|
||||
char* buf = ::realpath(path.c_str(), NULL);
|
||||
std::string p(buf);
|
||||
free(buf);
|
||||
return p;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -111,6 +111,12 @@ public:
|
||||
*/
|
||||
void concat( const std::string& p );
|
||||
|
||||
/**
|
||||
* Returns a string with the absolute pathname that names the same file, whose
|
||||
* resolution does not involve '.', '..', or symbolic links.
|
||||
*/
|
||||
std::string realpath() const;
|
||||
|
||||
/**
|
||||
* Get the file part of the path (everything after the last path sep)
|
||||
* @return file string
|
||||
|
Loading…
Reference in New Issue
Block a user