diff --git a/src/fs_impl/mod.rs b/src/fs_impl/mod.rs index b86bac9..5616739 100644 --- a/src/fs_impl/mod.rs +++ b/src/fs_impl/mod.rs @@ -6,6 +6,7 @@ use std::error::Error; use crate::lws_vfs::{Fstat, FileInfo}; extern crate winapi; +use io::Write; use winapi::um::winnt::{FILE_ATTRIBUTE_READONLY}; use std::os::windows::fs::MetadataExt; use std::os::windows::prelude::*; @@ -152,3 +153,44 @@ pub fn faccess(path: &String, mask: u32) -> Result> { let permissions = get_file_mode_mask(path); Ok(if permissions & mask != 0 {0} else {-1}) } + +#[test] +fn test() { + use crate::fs_impl::*; + let path = String::from("test.txt"); + let mut file: fs::File = fs::File::open("test.txt").unwrap(); + let _ = file.write(b"This is a test file.\n"); + let mut buffer = vec![0; 100]; + let mut size = 0; + let mut offsize: usize = 0; + let mut fi = FileInfo::default(); + size = 4; + let mut buffer = vec![0; size]; + offsize = 5; + let _ = fread(&path, &mut buffer, &mut size, offsize, &mut fi); + assert_eq!(buffer.len(), 4); + assert_eq!(buffer, b"is a"); + let result = fwrite(&path, &buffer, &mut size, offsize, &mut fi); + println!("result: {:?}", result); + println!("size: {:?}", size); + println!("buffer: {:?}", buffer); + let result = freaddir(&path, &mut vec![], 0, 0, &mut fi); + println!("result: {:?}", result); + println!("buffer: {:?}", buffer); + let result = fmkdir(&path, 0); + println!("result: {:?}", result); + let result = fchown(&path, 0, 0); + println!("result: {:?}", result); + let result = ftruncate(&path, 100); + println!("result: {:?}", result); + let result = futimens(&path, &vec![100, 0], &vec![100, 0]); + println!("result: {:?}", result); + let result = frelease(&path, &mut fi); + println!("result: {:?}", result); + let result = fsetxattr(&path, "test", &vec![1,2,3], 3, 0); + println!("result: {:?}", result); + let result = fgetxattr(&path, "test", 100); + println!("result: {:?}", result); + let result = faccess(&path, 0o777); + println!("result: {:?}", result); +} \ No newline at end of file