Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/dos_tests/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,14 @@ use rust_dos::*;

#[allow(dead_code)]
pub(crate) fn file_read_test() {
let test_file = dos::file::File::open("test.txt").unwrap();
let mut buffer = [0; 20];
let bytes_read = test_file.read(&mut buffer).unwrap();
println!("{} bytes read", bytes_read);
println!("{}", core::str::from_utf8(&buffer).unwrap());
match test_file.close() {
Ok(_) => println!("File closed"),
Err(_) => println!("Error closing file")
}

let test_file = dos::file::File::open("C:\\AUTOEXEC.BAT").unwrap();
let test_file = dos::file::File::open("C:\\AUTOEXEC.BAT");
let test_file = test_file.unwrap_or(dos::file::File::open("README.md").unwrap());
let mut buffer = [0; 100];
let bytes_read = test_file.read(&mut buffer).unwrap();
println!("{} bytes read", bytes_read);
println!("{}", core::str::from_utf8(&buffer).unwrap());

match test_file.close() {
Ok(_) => println!("File closed"),
Err(_) => println!("Error closing file")
}

println!("Hello, World!");
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ fn main() {
file_read_test();
datetime_test();
cooperative_multitasking_test();
println!("Hello, World!");
}