32
32
//! $ cargo run --example list_dir -- ./disk.img
33
33
//! ```
34
34
35
- extern crate embedded_sdmmc;
36
-
37
35
mod linux;
38
36
use linux:: * ;
39
37
40
- use embedded_sdmmc:: { Directory , VolumeIdx , VolumeManager } ;
38
+ use embedded_sdmmc:: { ShortFileName , VolumeIdx } ;
41
39
42
40
type Error = embedded_sdmmc:: Error < std:: io:: Error > ;
43
41
42
+ type Directory < ' a > = embedded_sdmmc:: Directory < ' a , LinuxBlockDevice , Clock , 8 , 4 , 4 > ;
43
+ type VolumeManager = embedded_sdmmc:: VolumeManager < LinuxBlockDevice , Clock , 8 , 4 , 4 > ;
44
+
44
45
fn main ( ) -> Result < ( ) , Error > {
45
46
env_logger:: init ( ) ;
46
47
let mut args = std:: env:: args ( ) . skip ( 1 ) ;
47
48
let filename = args. next ( ) . unwrap_or_else ( || "/dev/mmcblk0" . into ( ) ) ;
48
49
let print_blocks = args. find ( |x| x == "-v" ) . map ( |_| true ) . unwrap_or ( false ) ;
50
+
49
51
let lbd = LinuxBlockDevice :: new ( filename, print_blocks) . map_err ( Error :: DeviceError ) ?;
50
- let volume_mgr: VolumeManager < LinuxBlockDevice , Clock , 8 , 8 , 4 > =
51
- VolumeManager :: new_with_limits ( lbd, Clock , 0xAA00_0000 ) ;
52
+ let volume_mgr: VolumeManager = VolumeManager :: new_with_limits ( lbd, Clock , 0xAA00_0000 ) ;
52
53
let volume = volume_mgr. open_volume ( VolumeIdx ( 0 ) ) ?;
53
54
let root_dir = volume. open_root_dir ( ) ?;
54
55
list_dir ( root_dir, "/" ) ?;
@@ -58,10 +59,7 @@ fn main() -> Result<(), Error> {
58
59
/// Recursively print a directory listing for the open directory given.
59
60
///
60
61
/// The path is for display purposes only.
61
- fn list_dir (
62
- directory : Directory < LinuxBlockDevice , Clock , 8 , 8 , 4 > ,
63
- path : & str ,
64
- ) -> Result < ( ) , Error > {
62
+ fn list_dir ( directory : Directory < ' _ > , path : & str ) -> Result < ( ) , Error > {
65
63
println ! ( "Listing {}" , path) ;
66
64
let mut children = Vec :: new ( ) ;
67
65
directory. iterate_dir ( |entry| {
@@ -77,8 +75,8 @@ fn list_dir(
77
75
}
78
76
) ;
79
77
if entry. attributes . is_directory ( )
80
- && entry. name != embedded_sdmmc :: ShortFileName :: parent_dir ( )
81
- && entry. name != embedded_sdmmc :: ShortFileName :: this_dir ( )
78
+ && entry. name != ShortFileName :: parent_dir ( )
79
+ && entry. name != ShortFileName :: this_dir ( )
82
80
{
83
81
children. push ( entry. name . clone ( ) ) ;
84
82
}
0 commit comments