@ -172,6 +172,7 @@ public class BuildMetadataProtoFromXml extends Command {
metadataCollection . writeExternal ( out ) ;
out . close ( ) ;
} else {
deleteAllFilesForPrefix ( filePrefix ) ;
for ( PhoneMetadata metadata : metadataCollection . getMetadataList ( ) ) {
String regionCode = metadata . getId ( ) ;
/ / For non - geographical country calling codes ( e . g . + 800 ) , or for alternate formats , use the
@ -186,6 +187,7 @@ public class BuildMetadataProtoFromXml extends Command {
outMetadataCollection . writeExternal ( out ) ;
out . close ( ) ;
}
System . out . println ( "Generated " + metadataCollection . getMetadataCount ( ) + " new files" ) ;
}
Map < Integer , List < String > > countryCodeToRegionCodeMap =
@ -197,10 +199,26 @@ public class BuildMetadataProtoFromXml extends Command {
e . printStackTrace ( ) ;
return false ;
}
System . out . println ( "Metadata code successfully gener ated." ) ;
System . out . println ( "Metadata code successfully cre ated." ) ;
return true ;
}
private void deleteAllFilesForPrefix ( String filePrefix ) {
File [ ] allFiles = new File ( filePrefix ) . getParentFile ( ) . listFiles ( ) ;
if ( allFiles = = null ) {
allFiles = new File [ 0 ] ;
}
int counter = 0 ;
for ( File file : allFiles ) {
if ( file . getAbsolutePath ( ) . contains ( filePrefix ) ) {
if ( file . delete ( ) ) {
counter + + ;
}
}
}
System . out . println ( "Deleted " + counter + " old files" ) ;
}
private static final String MAP_COMMENT =
" // A mapping from a country code to the region codes which denote the\n" +
" // country/region represented by that country code. In the case of multiple\n" +