From: James Turner Date: Mon, 4 Jul 2016 08:04:46 +0000 (+0100) Subject: realpath returns a path, not a string. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6c69039be9619b3c3e8bfe96774792255acc09b1;p=simgear.git realpath returns a path, not a string. --- diff --git a/simgear/misc/sg_path.cxx b/simgear/misc/sg_path.cxx index d504e411..ffc2641a 100644 --- a/simgear/misc/sg_path.cxx +++ b/simgear/misc/sg_path.cxx @@ -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; } diff --git a/simgear/misc/sg_path.hxx b/simgear/misc/sg_path.hxx index 815960d7..f30b6a4b 100644 --- a/simgear/misc/sg_path.hxx +++ b/simgear/misc/sg_path.hxx @@ -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)