MCPcopy Create free account
hub / github.com/LibertyOS-Development/kernel / open

Method open

src/fs/directory.rs:201–239  ·  view source on GitHub ↗

Open

(pname: &str)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

mountedFunction · 0.85
rpathFunction · 0.85
isdirMethod · 0.80
intoMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected