@@ -26,6 +26,12 @@ use crate::bios::{bpb,fat};
2626use crate :: { DYNERR , STDRESULT } ;
2727
2828pub const FS_NAME : & str = "fat" ;
29+ const IMAGE_TYPES : [ img:: DiskImageType ; 4 ] = [
30+ img:: DiskImageType :: IMG ,
31+ img:: DiskImageType :: IMD ,
32+ img:: DiskImageType :: TD0 ,
33+ img:: DiskImageType :: DOT86F
34+ ] ;
2935
3036pub fn new_fimg ( chunk_len : usize , set_time : bool , path : & str ) -> Result < super :: FileImage , DYNERR > {
3137 if !pack:: is_path_valid ( path) {
@@ -121,6 +127,10 @@ impl Disk {
121127 }
122128 /// Test an image for the FAT file system.
123129 pub fn test_img ( img : & mut Box < dyn img:: DiskImage > ) -> bool {
130+ if !IMAGE_TYPES . contains ( & img. what_am_i ( ) ) {
131+ return false ;
132+ }
133+ log:: info!( "trying FAT" ) ;
124134 // test the boot sector to see if this is FAT
125135 if let Ok ( boot) = img. read_sector ( Track :: Num ( 0 ) , Sector :: Num ( 1 ) ) {
126136 return bpb:: BootSector :: verify ( & boot) ;
@@ -130,6 +140,10 @@ impl Disk {
130140 }
131141 /// Test an image for DOS 1.x (no signature, no BPB)
132142 pub fn test_img_dos1x ( img : & mut Box < dyn img:: DiskImage > ) -> bool {
143+ if !IMAGE_TYPES . contains ( & img. what_am_i ( ) ) {
144+ return false ;
145+ }
146+ log:: info!( "trying DOS 1.x" ) ;
133147 // We are going to look in the first FAT.
134148 // We look in the boot sector only for logging purposes.
135149 // By this time layout or size has already been used to create the `DiskImage`.
0 commit comments