mkdir may build a file instead of folder, so make it early