-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Based on #131
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
mod utils; | ||
|
||
static FILE_TO_READ: &str = "64MB.DAT"; | ||
|
||
#[test] | ||
fn read_file_with_seek() { | ||
let time_source = utils::make_time_source(); | ||
let disk = utils::make_block_device(utils::DISK_SOURCE).unwrap(); | ||
let mut volume_mgr = embedded_sdmmc::VolumeManager::new(disk, time_source); | ||
|
||
let mut volume = volume_mgr | ||
.open_volume(embedded_sdmmc::VolumeIdx(0)) | ||
.unwrap(); | ||
let mut root_dir = volume.open_root_dir().unwrap(); | ||
println!("\nReading file {}...", FILE_TO_READ); | ||
let mut f = root_dir | ||
.open_file_in_dir(FILE_TO_READ, embedded_sdmmc::Mode::ReadOnly) | ||
.unwrap(); | ||
f.seek_from_start(0x2c).unwrap(); | ||
while f.offset() < 1000000 { | ||
let mut buffer = [0u8; 2048]; | ||
f.read(&mut buffer).unwrap(); | ||
f.seek_from_current(-1024).unwrap(); | ||
} | ||
println!("Done!"); | ||
} |