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

Function read

src/fs/mod.rs:316–340  ·  view source on GitHub ↗

Read

(path: &str, buffer: &mut [u8])

Source from the content-addressed store, hash-verified

314
315// Read
316pub fn read(path: &str, buffer: &mut [u8]) -> Result<usize, ()>
317{
318 if let Some(info) = crate::sys::sc::info(&path)
319 {
320 let res = if info.isdev()
321 {
322 dev_open(&path)
323 }
324 else
325 {
326 file_open(&path)
327 };
328
329 if let Some(handle) = res
330 {
331 if let Some(bytes) = crate::sys::sc::read(handle, buffer)
332 {
333 crate::sys::sc::close(handle);
334 return Ok(bytes);
335 }
336 }
337 }
338
339 Err(())
340}
341
342
343// Read to bytes

Callers 3

disksizeFunction · 0.70
diskusedFunction · 0.70
read_to_bytesFunction · 0.70

Calls 6

dev_openFunction · 0.85
file_openFunction · 0.85
closeFunction · 0.85
isdevMethod · 0.80
infoFunction · 0.70
ErrEnum · 0.50

Tested by

no test coverage detected