get_ref_dir(): take the containing directory as argument