File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change
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 ! ( "\n Reading 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
+ }
You can’t perform that action at this time.
0 commit comments