Geoff McLane: realpath for Windows using _fullpath.

Also switch cygwin to use POSIX call.
This commit is contained in:
ThorstenB
2012-11-11 19:26:51 +01:00
parent 201cb61f84
commit dbea0c9361
+8 -5
View File
@@ -485,14 +485,18 @@ bool SGPath::rename(const SGPath& newName)
std::string SGPath::realpath() const std::string SGPath::realpath() const
{ {
#if defined(_WIN32) || (defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED <= 1050) #if (defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED <= 1050)
// Not implemented for Windows yet. Return original path instead.
// Workaround for Mac OS 10.5. Somehow fgfs crashes on Mac at ::realpath. // Workaround for Mac OS 10.5. Somehow fgfs crashes on Mac at ::realpath.
// simply returning path works on Mac since absolute path is passed from the GUI launcher // This means relative paths cannot be used on Mac OS <= 10.5
return path; return path;
#else #else
#if defined(_MSC_VER)
// with absPath NULL, will allocate, and ignore length
char *buf = _fullpath( NULL, path.c_str(), _MAX_PATH );
#else
// POSIX
char* buf = ::realpath(path.c_str(), NULL); char* buf = ::realpath(path.c_str(), NULL);
#endif
if (!buf) if (!buf)
{ {
SG_LOG(SG_IO, SG_ALERT, "ERROR: The path '" << path << "' does not exist in the file system."); SG_LOG(SG_IO, SG_ALERT, "ERROR: The path '" << path << "' does not exist in the file system.");
@@ -503,4 +507,3 @@ std::string SGPath::realpath() const
return p; return p;
#endif #endif
} }