Skip to content
Snippets Groups Projects
Commit 4b1a1568 authored by Paul Sajna's avatar Paul Sajna
Browse files

add rawfile.rs

parent 0157f7fc
No related branches found
No related tags found
No related merge requests found
use core::ops::Deref;
pub struct RawFile(usize);
impl RawFile {
pub fn open<T: AsRef<[u8]>>(path: T, flags: usize) -> Result<RawFile> {
open(path, flags).map(RawFile)
}
pub fn dup(&self, buf: &[u8]) -> Result<RawFile> {
dup(self.0, buf).map(RawFile)
}
}
impl Drop for RawFile {
fn drop(&mut self) {
let _ = close(self.0);
}
}
impl Deref for RawFile {
type Target = usize;
fn deref(&self) -> &usize {
&self.0
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment