Open
(pname: &str)
| 199 | |
| 200 | // Open |
| 201 | pub fn open(pname: &str) -> Option<Self> |
| 202 | { |
| 203 | if !crate::fs::blkdev::mounted() |
| 204 | { |
| 205 | return None; |
| 206 | } |
| 207 | |
| 208 | let mut directory = Directory::root(); |
| 209 | let pname = rpath(pname); |
| 210 | |
| 211 | if pname == "/" |
| 212 | { |
| 213 | return Some(directory); |
| 214 | } |
| 215 | |
| 216 | for name in pname.trim_start_matches('/').split('/') |
| 217 | { |
| 218 | match directory.find(name) |
| 219 | { |
| 220 | Some(directory_entry) => |
| 221 | { |
| 222 | if directory_entry.isdir() |
| 223 | { |
| 224 | directory = directory_entry.into() |
| 225 | } |
| 226 | else |
| 227 | { |
| 228 | return None; |
| 229 | } |
| 230 | }, |
| 231 | |
| 232 | None => |
| 233 | { |
| 234 | return None |
| 235 | }, |
| 236 | } |
| 237 | } |
| 238 | Some(directory) |
| 239 | } |
| 240 | |
| 241 | |
| 242 | // Remove |