Skip to content

Commit 83128a3

Browse files
committed
Add new test.
Based on #131
1 parent 44b63de commit 83128a3

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/read_file_with_seek.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
mod utils;
2+
3+
static FILE_TO_READ: &str = "64MB.DAT";
4+
5+
#[test]
6+
fn read_file_with_seek() {
7+
let time_source = utils::make_time_source();
8+
let disk = utils::make_block_device(utils::DISK_SOURCE).unwrap();
9+
let mut volume_mgr = embedded_sdmmc::VolumeManager::new(disk, time_source);
10+
11+
let mut volume = volume_mgr
12+
.open_volume(embedded_sdmmc::VolumeIdx(0))
13+
.unwrap();
14+
let mut root_dir = volume.open_root_dir().unwrap();
15+
println!("\nReading file {}...", FILE_TO_READ);
16+
let mut f = root_dir
17+
.open_file_in_dir(FILE_TO_READ, embedded_sdmmc::Mode::ReadOnly)
18+
.unwrap();
19+
f.seek_from_start(0x2c).unwrap();
20+
while f.offset() < 1000000 {
21+
let mut buffer = [0u8; 2048];
22+
f.read(&mut buffer).unwrap();
23+
f.seek_from_current(-1024).unwrap();
24+
}
25+
println!("Done!");
26+
}

0 commit comments

Comments
 (0)