mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 21:35:00 +00:00
Use Simplified
instead of Normalized
for path prefix stripping (#2071)
## Summary This directly matches the naming of the `dunce` methods.
This commit is contained in:
parent
f315d07133
commit
ef15098288
26 changed files with 129 additions and 129 deletions
|
@ -96,7 +96,7 @@ pub async fn write_atomic(path: impl AsRef<Path>, data: impl AsRef<[u8]>) -> std
|
|||
std::io::ErrorKind::Other,
|
||||
format!(
|
||||
"Failed to persist temporary file to {}: {}",
|
||||
path.normalized_display(),
|
||||
path.simplified_display(),
|
||||
err.error
|
||||
),
|
||||
)
|
||||
|
@ -117,7 +117,7 @@ pub fn write_atomic_sync(path: impl AsRef<Path>, data: impl AsRef<[u8]>) -> std:
|
|||
std::io::ErrorKind::Other,
|
||||
format!(
|
||||
"Failed to persist temporary file to {}: {}",
|
||||
path.normalized_display(),
|
||||
path.simplified_display(),
|
||||
err.error
|
||||
),
|
||||
)
|
||||
|
@ -229,7 +229,7 @@ impl LockedFile {
|
|||
warn_user!(
|
||||
"Waiting to acquire lock for {} (lockfile: {})",
|
||||
resource,
|
||||
path.normalized_display(),
|
||||
path.simplified_display(),
|
||||
);
|
||||
file.file().lock_exclusive()?;
|
||||
Ok(Self(file))
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
use std::borrow::Cow;
|
||||
use std::path::Path;
|
||||
|
||||
pub trait Normalized {
|
||||
/// Normalize a [`Path`].
|
||||
pub trait Simplified {
|
||||
/// Simplify a [`Path`].
|
||||
///
|
||||
/// On Windows, this will strip the `\\?\` prefix from paths. On other platforms, it's a no-op.
|
||||
fn normalized(&self) -> &Path;
|
||||
fn simplified(&self) -> &Path;
|
||||
|
||||
/// Render a [`Path`] for user-facing display.
|
||||
///
|
||||
/// On Windows, this will strip the `\\?\` prefix from paths. On other platforms, it's
|
||||
/// equivalent to [`std::path::Display`].
|
||||
fn normalized_display(&self) -> std::path::Display;
|
||||
fn simplified_display(&self) -> std::path::Display;
|
||||
}
|
||||
|
||||
impl<T: AsRef<Path>> Normalized for T {
|
||||
fn normalized(&self) -> &Path {
|
||||
impl<T: AsRef<Path>> Simplified for T {
|
||||
fn simplified(&self) -> &Path {
|
||||
dunce::simplified(self.as_ref())
|
||||
}
|
||||
|
||||
fn normalized_display(&self) -> std::path::Display {
|
||||
fn simplified_display(&self) -> std::path::Display {
|
||||
dunce::simplified(self.as_ref()).display()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue