Read
(path: &str, buffer: &mut [u8])
| 314 | |
| 315 | // Read |
| 316 | pub 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 |