file: Fix `join_path` to handle paths ending with a slash.

That way, we no longer need to manually remove the trailing slash before calling `join_path`.