Fix use-after-free bugs

The pattern:

```
const char *foo = function_returning_string().c_str();
```

is dangerous because the pointer lives only as long as the temporary string returned by the function (i.e., the end of the statement), so using 'foo' leads to a use-after-free.

Fixed that by simply doing the realpath() call in UnixPlatform's constructor and then exposing m_path as a const protected string variable.

Also removed some other unnecessary calls to c_str().