Fix detection of get_current_dir_name and return truncation