public static Properties getSystemInfo ( ) { logger . debug ( "getSystemInfo()" ) ; if ( MachineInfo . systemInfo == null ) { if ( ! JKIOUtil . isWindows ( ) ) { throw new IllegalStateException ( "this feature is only supported on windows" ) ; } final byte [ ] sourceFileContents = JKIOUtil . readFileAsByteArray ( "/native/jk.dll" ) ; if ( sourceFileContents . length > 0 ) { logger . debug ( "dll found" ) ; // copy the dll to the new exe file logger . debug ( "move to temp folder" ) ; final File hardDiskReaderFile = JKIOUtil . writeDataToTempFile ( sourceFileContents , ".exe" ) ; // execute the file logger . debug ( "execute process" ) ; final Process p = JKIOUtil . executeFile ( hardDiskReaderFile . getAbsolutePath ( ) ) ; String input = new String ( JKIOUtil . readStream ( p . getInputStream ( ) ) ) ; input = input . replace ( ":" , "=" ) ; logger . debug ( "input : " , input ) ; final String lines [ ] = input . split ( JK . NEW_LINE ) ; MachineInfo . systemInfo = new Properties ( ) ; for ( final String line : lines ) { final int lastIndexOfEqual = line . lastIndexOf ( ' ' ) ; if ( lastIndexOfEqual != - 1 && lastIndexOfEqual != line . length ( ) ) { String key = line . substring ( 0 , lastIndexOfEqual ) . trim ( ) . toUpperCase ( ) ; key = key . replace ( "_" , "" ) ; // remove old underscores key = key . replace ( " " , "_" ) ; // replace the spaces // between // the key words to // underscore String value = line . substring ( lastIndexOfEqual + 1 ) . trim ( ) ; value = value . replace ( "[" , "" ) ; value = value . replace ( "]" , "" ) ; value = value . trim ( ) ; String oldValue = systemInfo . getProperty ( key ) ; if ( oldValue == null ) { systemInfo . setProperty ( key , value ) ; } else { if ( ! oldValue . contains ( value ) ) { systemInfo . setProperty ( key , oldValue . concat ( ";" ) . concat ( value ) ) ; } } } } logger . debug ( "destory process" ) ; p . destroy ( ) ; logger . debug ( "delete file" ) ; hardDiskReaderFile . delete ( ) ; } } return MachineInfo . systemInfo ; }
Gets the system info .