1*01c18c64Ssparkzky use alloc::string::String; 2004e86ffSlogin use core::char::REPLACEMENT_CHARACTER; 3004e86ffSlogin 4004e86ffSlogin /// FAT文件系统保留开头的2个簇 5004e86ffSlogin pub const RESERVED_CLUSTERS: u32 = 2; 6004e86ffSlogin 7004e86ffSlogin /// @brief 将u8转为ascii字符。 8004e86ffSlogin /// 当转码成功时,返回对应的ascii字符,否则返回Unicode占位符 decode_u8_ascii(value: u8) -> char9*01c18c64Ssparkzkypub(super) fn decode_u8_ascii(value: u8) -> char { 10004e86ffSlogin if value <= 0x7f { 11004e86ffSlogin return value as char; 12004e86ffSlogin } else { 13004e86ffSlogin // 如果不是ascii字符,则返回Unicode占位符 U+FFFD 14004e86ffSlogin return REPLACEMENT_CHARACTER; 15004e86ffSlogin } 16004e86ffSlogin } 17*01c18c64Ssparkzky 18*01c18c64Ssparkzky /// 把名称转为inode缓存里面的key 19*01c18c64Ssparkzky #[inline(always)] to_search_name(name: &str) -> String20*01c18c64Ssparkzkypub(super) fn to_search_name(name: &str) -> String { 21*01c18c64Ssparkzky name.to_ascii_uppercase() 22*01c18c64Ssparkzky } 23*01c18c64Ssparkzky 24*01c18c64Ssparkzky /// 把名称转为inode缓存里面的key(输入为string,原地替换) 25*01c18c64Ssparkzky #[inline(always)] to_search_name_string(mut name: String) -> String26*01c18c64Ssparkzkypub(super) fn to_search_name_string(mut name: String) -> String { 27*01c18c64Ssparkzky name.make_ascii_uppercase(); 28*01c18c64Ssparkzky name 29*01c18c64Ssparkzky } 30