Modified to compile on Windows

Thanks to Nach M. S. for a realpath() replacement