forked from M-Labs/rust-fatfs
Rename methods: bytes -> as_bytes
This commit is contained in:
parent
69b7675940
commit
c4a1bc70ec
@ -240,7 +240,7 @@ impl <'a, T: ReadWriteSeek + 'a> Dir<'a, T> {
|
||||
// check if directory contains no files
|
||||
for r in self.iter() {
|
||||
let e = r?;
|
||||
let name = e.short_file_name_bytes();
|
||||
let name = e.short_file_name_as_bytes();
|
||||
// ignore special entries "." and ".."
|
||||
if name != ".".as_bytes() && name != "..".as_bytes() {
|
||||
return Ok(false);
|
||||
|
@ -71,21 +71,21 @@ impl ShortName {
|
||||
}
|
||||
}
|
||||
|
||||
fn bytes(&self) -> &[u8] {
|
||||
fn as_bytes(&self) -> &[u8] {
|
||||
&self.name[..self.len as usize]
|
||||
}
|
||||
|
||||
#[cfg(feature = "alloc")]
|
||||
fn to_string(&self) -> String {
|
||||
// Strip non-ascii characters from short name
|
||||
let char_iter = self.bytes().iter().cloned().map(decode_oem_char_lossy);
|
||||
let char_iter = self.as_bytes().iter().cloned().map(decode_oem_char_lossy);
|
||||
// Build string from character iterator
|
||||
String::from_iter(char_iter)
|
||||
}
|
||||
|
||||
fn eq_ignore_ascii_case(&self, name: &str) -> bool {
|
||||
// Strip non-ascii characters from short name
|
||||
let char_iter = self.bytes().iter().cloned().map(decode_oem_char_lossy).map(|c| c.to_ascii_uppercase());
|
||||
let char_iter = self.as_bytes().iter().cloned().map(decode_oem_char_lossy).map(|c| c.to_ascii_uppercase());
|
||||
// Build string from character iterator
|
||||
char_iter.eq(name.chars().map(|c| c.to_ascii_uppercase()))
|
||||
}
|
||||
@ -645,8 +645,8 @@ impl <'a, T: ReadWriteSeek> DirEntry<'a, T> {
|
||||
/// Returns short file name as byte array slice.
|
||||
///
|
||||
/// Characters are encoded in the OEM codepage.
|
||||
pub fn short_file_name_bytes(&self) -> &[u8] {
|
||||
self.short_name.bytes()
|
||||
pub fn short_file_name_as_bytes(&self) -> &[u8] {
|
||||
self.short_name.as_bytes()
|
||||
}
|
||||
|
||||
/// Returns long file name or if it doesn't exist fallbacks to short file name.
|
||||
|
@ -442,7 +442,7 @@ impl <T: ReadWriteSeek> FileSystem<T> {
|
||||
#[cfg(feature = "alloc")]
|
||||
pub fn volume_label(&self) -> String {
|
||||
// Strip non-ascii characters from volume label
|
||||
let char_iter = self.volume_label_bytes().iter().cloned().map(decode_oem_char_lossy);
|
||||
let char_iter = self.volume_label_as_bytes().iter().cloned().map(decode_oem_char_lossy);
|
||||
// Build string from character iterator
|
||||
String::from_iter(char_iter)
|
||||
}
|
||||
@ -452,7 +452,7 @@ impl <T: ReadWriteSeek> FileSystem<T> {
|
||||
/// Label is encoded in the OEM codepage.
|
||||
/// Note: File with `VOLUME_ID` attribute in root directory is ignored by this library.
|
||||
/// Only label from BPB is used.
|
||||
pub fn volume_label_bytes(&self) -> &[u8] {
|
||||
pub fn volume_label_as_bytes(&self) -> &[u8] {
|
||||
let full_label_slice = &self.bpb.volume_label;
|
||||
let len = full_label_slice.iter().rposition(|b| *b != 0x20).map(|p| p + 1).unwrap_or(0);
|
||||
&full_label_slice[..len]
|
||||
|
Loading…
Reference in New Issue
Block a user