mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
..
This commit is contained in:
parent
0eef82e06e
commit
4e2e682cef
2 changed files with 33 additions and 31 deletions
|
|
@ -145,7 +145,9 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn as_loc<'a>(&'a self) -> Loc<'a, P::Borrowed> { Loc::from(self) }
|
pub fn as_loc<'a>(&'a self) -> Loc<'a, P::Borrowed> {
|
||||||
|
Loc { inner: self.inner.as_ref(), uri: self.uri, urn: self.urn }
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn to_path(&self) -> P
|
pub fn to_path(&self) -> P
|
||||||
|
|
|
||||||
|
|
@ -7,31 +7,31 @@ pub trait PathLike: AsRef<Self> {
|
||||||
where
|
where
|
||||||
Self: 'a;
|
Self: 'a;
|
||||||
|
|
||||||
|
fn components(&self) -> Self::Components<'_>;
|
||||||
|
|
||||||
fn default() -> &'static Self;
|
fn default() -> &'static Self;
|
||||||
|
|
||||||
fn strip_prefix<T>(&self, base: T) -> Option<&Self>
|
fn encoded_bytes(&self) -> &[u8];
|
||||||
where
|
|
||||||
T: AsRef<Self>;
|
|
||||||
|
|
||||||
fn len(&self) -> usize { self.encoded_bytes().len() }
|
fn extension(&self) -> Option<&Self::Inner>;
|
||||||
|
|
||||||
fn components(&self) -> Self::Components<'_>;
|
|
||||||
|
|
||||||
fn file_name(&self) -> Option<&Self::Inner>;
|
fn file_name(&self) -> Option<&Self::Inner>;
|
||||||
|
|
||||||
fn file_stem(&self) -> Option<&Self::Inner>;
|
fn file_stem(&self) -> Option<&Self::Inner>;
|
||||||
|
|
||||||
fn extension(&self) -> Option<&Self::Inner>;
|
|
||||||
|
|
||||||
fn parent(&self) -> Option<&Self>;
|
|
||||||
|
|
||||||
fn encoded_bytes(&self) -> &[u8];
|
|
||||||
|
|
||||||
unsafe fn from_encoded_bytes(bytes: &[u8]) -> &Self;
|
unsafe fn from_encoded_bytes(bytes: &[u8]) -> &Self;
|
||||||
|
|
||||||
fn join<T>(&self, base: T) -> Self::Owned
|
fn join<T>(&self, base: T) -> Self::Owned
|
||||||
where
|
where
|
||||||
T: AsRef<Self>;
|
T: AsRef<Self>;
|
||||||
|
|
||||||
|
fn len(&self) -> usize { self.encoded_bytes().len() }
|
||||||
|
|
||||||
|
fn parent(&self) -> Option<&Self>;
|
||||||
|
|
||||||
|
fn strip_prefix<T>(&self, base: T) -> Option<&Self>
|
||||||
|
where
|
||||||
|
T: AsRef<Self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PathBufLike: AsRef<Self::Borrowed> + Default + 'static {
|
pub trait PathBufLike: AsRef<Self::Borrowed> + Default + 'static {
|
||||||
|
|
@ -39,13 +39,13 @@ pub trait PathBufLike: AsRef<Self::Borrowed> + Default + 'static {
|
||||||
type InnerRef: ?Sized + PathInner;
|
type InnerRef: ?Sized + PathInner;
|
||||||
type Borrowed: ?Sized + PathLike + AsRef<Self::Borrowed>;
|
type Borrowed: ?Sized + PathLike + AsRef<Self::Borrowed>;
|
||||||
|
|
||||||
fn len(&self) -> usize { self.encoded_bytes().len() }
|
|
||||||
|
|
||||||
fn encoded_bytes(&self) -> &[u8];
|
fn encoded_bytes(&self) -> &[u8];
|
||||||
|
|
||||||
|
unsafe fn from_encoded_bytes(bytes: Vec<u8>) -> Self;
|
||||||
|
|
||||||
fn into_encoded_bytes(self) -> Vec<u8>;
|
fn into_encoded_bytes(self) -> Vec<u8>;
|
||||||
|
|
||||||
unsafe fn from_encoded_bytes(bytes: Vec<u8>) -> Self;
|
fn len(&self) -> usize { self.encoded_bytes().len() }
|
||||||
|
|
||||||
fn set_file_name<T>(&mut self, name: T)
|
fn set_file_name<T>(&mut self, name: T)
|
||||||
where
|
where
|
||||||
|
|
@ -63,27 +63,18 @@ impl PathLike for Path {
|
||||||
type Inner = OsStr;
|
type Inner = OsStr;
|
||||||
type Owned = PathBuf;
|
type Owned = PathBuf;
|
||||||
|
|
||||||
|
fn components(&self) -> Self::Components<'_> { self.components() }
|
||||||
|
|
||||||
fn default() -> &'static Self { Path::new("") }
|
fn default() -> &'static Self { Path::new("") }
|
||||||
|
|
||||||
fn strip_prefix<T>(&self, base: T) -> Option<&Self>
|
fn encoded_bytes(&self) -> &[u8] { self.as_os_str().as_encoded_bytes() }
|
||||||
where
|
|
||||||
T: AsRef<Self>,
|
|
||||||
{
|
|
||||||
self.strip_prefix(base).ok()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn components(&self) -> Self::Components<'_> { self.components() }
|
fn extension(&self) -> Option<&Self::Inner> { self.extension() }
|
||||||
|
|
||||||
fn file_name(&self) -> Option<&Self::Inner> { self.file_name() }
|
fn file_name(&self) -> Option<&Self::Inner> { self.file_name() }
|
||||||
|
|
||||||
fn file_stem(&self) -> Option<&Self::Inner> { self.file_stem() }
|
fn file_stem(&self) -> Option<&Self::Inner> { self.file_stem() }
|
||||||
|
|
||||||
fn extension(&self) -> Option<&Self::Inner> { self.extension() }
|
|
||||||
|
|
||||||
fn parent(&self) -> Option<&Self> { self.parent() }
|
|
||||||
|
|
||||||
fn encoded_bytes(&self) -> &[u8] { self.as_os_str().as_encoded_bytes() }
|
|
||||||
|
|
||||||
unsafe fn from_encoded_bytes(bytes: &[u8]) -> &Self {
|
unsafe fn from_encoded_bytes(bytes: &[u8]) -> &Self {
|
||||||
Self::new(unsafe { Self::Inner::from_encoded_bytes_unchecked(bytes) })
|
Self::new(unsafe { Self::Inner::from_encoded_bytes_unchecked(bytes) })
|
||||||
}
|
}
|
||||||
|
|
@ -94,6 +85,15 @@ impl PathLike for Path {
|
||||||
{
|
{
|
||||||
self.join(base)
|
self.join(base)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn parent(&self) -> Option<&Self> { self.parent() }
|
||||||
|
|
||||||
|
fn strip_prefix<T>(&self, base: T) -> Option<&Self>
|
||||||
|
where
|
||||||
|
T: AsRef<Self>,
|
||||||
|
{
|
||||||
|
self.strip_prefix(base).ok()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PathBufLike for PathBuf {
|
impl PathBufLike for PathBuf {
|
||||||
|
|
@ -103,12 +103,12 @@ impl PathBufLike for PathBuf {
|
||||||
|
|
||||||
fn encoded_bytes(&self) -> &[u8] { self.as_os_str().as_encoded_bytes() }
|
fn encoded_bytes(&self) -> &[u8] { self.as_os_str().as_encoded_bytes() }
|
||||||
|
|
||||||
fn into_encoded_bytes(self) -> Vec<u8> { self.into_os_string().into_encoded_bytes() }
|
|
||||||
|
|
||||||
unsafe fn from_encoded_bytes(bytes: Vec<u8>) -> Self {
|
unsafe fn from_encoded_bytes(bytes: Vec<u8>) -> Self {
|
||||||
Self::from(unsafe { Self::Inner::from_encoded_bytes_unchecked(bytes) })
|
Self::from(unsafe { Self::Inner::from_encoded_bytes_unchecked(bytes) })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn into_encoded_bytes(self) -> Vec<u8> { self.into_os_string().into_encoded_bytes() }
|
||||||
|
|
||||||
fn set_file_name<T>(&mut self, name: T)
|
fn set_file_name<T>(&mut self, name: T)
|
||||||
where
|
where
|
||||||
T: AsRef<Self::InnerRef>,
|
T: AsRef<Self::InnerRef>,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue