diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index ae57786a6..78915e725 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -29,15 +29,9 @@ #include #include // strcmp() -#if defined( unix ) || defined( __CYGWIN__ ) -# include // for gethostname() -#endif #ifdef _WIN32 -# include // for getcwd() -# define getcwd _getcwd # include // isatty() # define isatty _isatty -# include "winsock2.h" // for gethostname() #endif // work around a stdc++ lib bug in some versions of linux, but doesn't @@ -1027,12 +1021,11 @@ bool fgInitGeneral() { globals->set_browser(fgGetString("/sim/startup/browser-app", "firefox %u")); - char buf[512], *cwd = getcwd(buf, 511); - buf[511] = '\0'; + simgear::Dir cwd(simgear::Dir::current()); SGPropertyNode *curr = fgGetNode("/sim", true); curr->removeChild("fg-current", 0, false); curr = curr->getChild("fg-current", 0, true); - curr->setStringValue(cwd ? cwd : ""); + curr->setStringValue(cwd.path().str()); curr->setAttribute(SGPropertyNode::WRITE, false); fgSetBool("/sim/startup/stdout-to-terminal", isatty(1) != 0 );