Re: [PATCH v4 1/2] abspath: add a function to resolve paths with missing components
From: brian m. carlson <hidden>
Date: 2020-12-08 02:52:37
Attachments
- signature.asc [application/pgp-signature] 263 bytes
From: brian m. carlson <hidden>
Date: 2020-12-08 02:52:37
On 2020-12-07 at 17:19:32, René Scharfe wrote:
I find the concept of a "real" path with imaginary components strangely amusing. But perhaps a name like strbuf_resolve_path() would fit better?
I think I'm going to take the strbuf_realpath_forgiving solution from Eric Sunshine because I think having similar names for similar functions helps discoverability.
So the original code errors out if there is a real error (errno != ENOENT). It also errors out if any component except the last one is missing (errno == ENOENT && remaining.len); that's what the comment is about. This patch adds the ability to ignore ENOENT for all components. Perhaps convert many_missing and die_on_error into a single flags parameter and implement the flags DIE_ON_ERR and REQUIRE_BASENAME or similar? Callers would be easier to read because such an interface is self-documenting -- provided we find good flag names.
As discussed elsewhere in the thread, this will be moving to an internal function, but I can make that function take two flag parameters. -- brian m. carlson (he/him or they/them) Houston, Texas, US