mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-15 08:56:47 +00:00
1.重构:VFS 2. 重构:ProcFS 3. 重构:DevFS 4. 重构:FAT32 5. 重构:AHCI驱动 6. 新增:RamFS 7. 新增:MountFS 8. 新增:FAT12 9. 新增:FAT16 10. 重构:设备抽象 Co-authored-by: guanjinquan <1666320330@qq.com> Co-authored-by: DaJiYuQia <88259094+DaJiYuQia@users.noreply.github.com>
22 lines
918 B
Rust
22 lines
918 B
Rust
/// @brief 切分路径字符串,返回最左侧那一级的目录名和剩余的部分。
|
|
///
|
|
/// 举例:对于 /123/456/789/ 本函数返回的第一个值为123, 第二个值为456/789
|
|
pub fn split_path(path: &str) -> (&str, Option<&str>) {
|
|
let mut path_split: core::str::SplitN<&str> = path.trim_matches('/').splitn(2, "/");
|
|
let comp = path_split.next().unwrap_or("");
|
|
let rest_opt = path_split.next();
|
|
|
|
return (comp, rest_opt);
|
|
}
|
|
|
|
/// @brief 切分路径字符串,返回最右侧那一级的目录名和剩余的部分。
|
|
///
|
|
/// 举例:对于 /123/456/789/ 本函数返回的第一个值为789, 第二个值为123/456
|
|
pub fn rsplit_path(path: &str) -> (&str, Option<&str>) {
|
|
let mut path_split: core::str::RSplitN<&str> = path.trim_matches('/').rsplitn(2, "/");
|
|
let comp = path_split.next().unwrap_or("");
|
|
let rest_opt = path_split.next();
|
|
|
|
return (comp, rest_opt);
|
|
}
|