only `takeDirectory` if tgt is a file