2020-12-13 11:07:19 +04:00
|
|
|
mod pipe;
|
|
|
|
mod stdio;
|
2020-12-19 20:52:14 +04:00
|
|
|
mod inode;
|
2020-12-13 11:07:19 +04:00
|
|
|
|
|
|
|
use crate::mm::UserBuffer;
|
|
|
|
use core::any::Any;
|
|
|
|
|
|
|
|
pub trait File : Any + Send + Sync {
|
2020-12-19 20:52:14 +04:00
|
|
|
fn readable(&self) -> bool;
|
|
|
|
fn writable(&self) -> bool;
|
2020-12-13 11:07:19 +04:00
|
|
|
fn read(&self, buf: UserBuffer) -> usize;
|
|
|
|
fn write(&self, buf: UserBuffer) -> usize;
|
|
|
|
fn as_any_ref(&self) -> &dyn Any;
|
|
|
|
}
|
|
|
|
|
|
|
|
impl dyn File {
|
2020-12-14 12:18:33 +04:00
|
|
|
#[allow(unused)]
|
2020-12-13 11:07:19 +04:00
|
|
|
pub fn downcast_ref<T: File>(&self) -> Option<&T> {
|
|
|
|
self.as_any_ref().downcast_ref::<T>()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-14 12:18:33 +04:00
|
|
|
pub use pipe::{Pipe, make_pipe};
|
2020-12-19 20:52:14 +04:00
|
|
|
pub use stdio::{Stdin, Stdout};
|
|
|
|
pub use inode::{OSInode, open_file, OpenFlags, list_apps};
|