private ProjectFile handleDatabaseInDirectory ( File directory ) throws Exception { byte [ ] buffer = new byte [ BUFFER_SIZE ] ; File [ ] files = directory . listFiles ( ) ; if ( files != null ) { for ( File file : files ) { if ( file . isDirectory ( ) ) { continue ; } FileInputStream fis = new FileInputStream ( file ) ; int bytesRead = fis . read ( buffer ) ; fis . close ( ) ; // // If the file is smaller than the buffer we are peeking into, // it's probably not a valid schedule file. // if ( bytesRead != BUFFER_SIZE ) { continue ; } if ( matchesFingerprint ( buffer , BTRIEVE_FINGERPRINT ) ) { return handleP3BtrieveDatabase ( directory ) ; } if ( matchesFingerprint ( buffer , STW_FINGERPRINT ) ) { return handleSureTrakDatabase ( directory ) ; } } } return null ; }
Given a directory determine if it contains a multi - file database whose format we can process .