Use getcwd()/chdir() instead of open()/fchdir(). This was suggested by Disastry to make the WIN32 port easier.
Changed paths: