redox/kernel/scheme/debug.rs

35 lines
908 B
Rust
Raw Normal View History

2016-08-15 05:38:32 +02:00
use core::str;
2016-08-26 01:03:01 +02:00
2016-08-15 05:38:32 +02:00
use syscall::Result;
use super::Scheme;
2016-08-15 05:38:32 +02:00
pub struct DebugScheme;
impl Scheme for DebugScheme {
2016-08-18 00:54:48 +02:00
fn open(&mut self, path: &[u8], _flags: usize) -> Result<usize> {
2016-08-15 05:38:32 +02:00
println!("DebugScheme::open: {}", unsafe { str::from_utf8_unchecked(path) });
Ok(0)
}
/// Read the file `number` into the `buffer`
///
/// Returns the number of bytes read
fn read(&mut self, _file: usize, _buffer: &mut [u8]) -> Result<usize> {
2016-08-15 05:38:32 +02:00
Ok(0)
}
/// Write the `buffer` to the `file`
///
/// Returns the number of bytes written
fn write(&mut self, _file: usize, buffer: &[u8]) -> Result<usize> {
2016-08-15 05:38:32 +02:00
//TODO: Write bytes, do not convert to str
print!("{}", unsafe { str::from_utf8_unchecked(buffer) });
Ok(buffer.len())
}
/// Close the file `number`
fn close(&mut self, _file: usize) -> Result<()> {
2016-08-15 05:38:32 +02:00
Ok(())
}
}