For logical consistency, check_for_dir_match should be got_dir_match. Most of our functions return 0 on non-error, not 1