Fix endless loop on windows servers

Directory seperator is \ on windows
However we can just check for path != dirname(path) because that is
the same for '' (empty string), '.' and DIRECTORY_SEPARATOR on all OS