@@ -12,9 +12,12 @@ use crate::dir::{
1212 gen2:: Directory as Gen2Directory ,
1313 gen3:: { CPD_MAGIC_BYTES , CodePartitionDirectory } ,
1414} ;
15- use crate :: part:: gen2:: Gen2Partition ;
15+ use crate :: part:: fpt:: FTPR ;
16+ use crate :: part:: part:: Partition ;
1617use crate :: part:: {
1718 fpt:: { FPT , MIN_FPT_SIZE } ,
19+ gen2:: Gen2Partition ,
20+ gen3:: Gen3Partition ,
1821 part:: ClearOptions ,
1922 partitions:: Partitions ,
2023} ;
@@ -66,6 +69,32 @@ impl FPTArea {
6669 }
6770 }
6871
72+ pub fn check_ftpr_sig ( & self ) -> Result < ( ) , String > {
73+ match & self . partitions {
74+ Partitions :: Gen2 ( parts) => {
75+ if let Some ( ftpr) = parts. iter ( ) . find ( |p| p. entry ( ) . name ( ) == FTPR ) {
76+ match ftpr {
77+ Gen2Partition :: Dir ( dir) => dir. check_signature ( ) ,
78+ _ => Err ( "FTPR partition not recognized as directory" . into ( ) ) ,
79+ }
80+ } else {
81+ Err ( "FTPR partition not found" . into ( ) )
82+ }
83+ }
84+ Partitions :: Gen3 ( parts) => {
85+ if let Some ( ftpr) = parts. iter ( ) . find ( |p| p. entry ( ) . name ( ) == FTPR ) {
86+ match ftpr {
87+ Gen3Partition :: Dir ( dir) => dir. check_signature ( ) ,
88+ _ => Err ( "FTPR partition not recognized as directory" . into ( ) ) ,
89+ }
90+ } else {
91+ Err ( "FTPR partition not found" . into ( ) )
92+ }
93+ }
94+ _ => Err ( "no recognized as ME generation 2 or 3" . into ( ) ) ,
95+ }
96+ }
97+
6998 pub fn relocate_partitions ( & mut self ) -> Result < ( ) , String > {
7099 let sorted_parts = & self . partitions . get_sorted ( ) ;
71100 let first = sorted_parts
0 commit comments