diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:42 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:42 +0000 |
commit | 837b550238aa671a591ccf282dddeab29cadb206 (patch) | |
tree | 914b6b8862bace72bd3245ca184d374b08d8a672 /vendor/gix-path/src/convert.rs | |
parent | Adding debian version 1.70.0+dfsg2-1. (diff) | |
download | rustc-837b550238aa671a591ccf282dddeab29cadb206.tar.xz rustc-837b550238aa671a591ccf282dddeab29cadb206.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-path/src/convert.rs')
-rw-r--r-- | vendor/gix-path/src/convert.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/vendor/gix-path/src/convert.rs b/vendor/gix-path/src/convert.rs index 6a949529f..d8bf70353 100644 --- a/vendor/gix-path/src/convert.rs +++ b/vendor/gix-path/src/convert.rs @@ -82,6 +82,16 @@ pub fn into_bstr<'a>(path: impl Into<Cow<'a, Path>>) -> Cow<'a, BStr> { try_into_bstr(path).expect("prefix path doesn't contain ill-formed UTF-8") } +/// Join `path` to `base` such that they are separated with a `/`, i.e. `base/path`. +pub fn join_bstr_unix_pathsep<'a, 'b>(base: impl Into<Cow<'a, BStr>>, path: impl Into<&'b BStr>) -> Cow<'a, BStr> { + let mut base = base.into(); + if !base.is_empty() && base.last() != Some(&b'/') { + base.to_mut().push(b'/'); + } + base.to_mut().extend_from_slice(path.into()); + base +} + /// Given `input` bytes, produce a `Path` from them ignoring encoding entirely if on unix. /// /// On windows, the input is required to be valid UTF-8, which is guaranteed if we wrote it before. There are some potential |