fix newline issue for win32, do dirname stuff