void IbisHardwareModule::WriteHardwareConfig() { QString filename = GetIbisAPI()->GetConfigDirectory() + IbisHardwareModuleConfigFilename; // make sure directory exists. Possible filename doesn't exist, but dir has to exist and be writable QFileInfo info( filename ); QFileInfo dirInfo( info.dir().path() ); // get the parent dir QString generalConfigFileName( filename ); if( !dirInfo.exists() || !dirInfo.isWritable() || (info.exists() && !info.isWritable()) ) { QString message; if( !dirInfo.exists() ) message = QString( "Directory %1 used to store hardware settings doesn't exist." ).arg( info.dir().path() ); else if( !dirInfo.isWritable() ) message = QString( "Directory %1 used to store hardware settings is not writable." ).arg( info.dir().path() ); else message = QString( "Hardware config file %1 is not writable." ).arg( filename ); generalConfigFileName = QDir::homePath() + "/hardware_config.xml"; message += QString(" Hardware config will be saved in %1").arg( generalConfigFileName ); QMessageBox::warning( 0, "Warning", message ); } // write the config file InternalWriteHardwareConfig( generalConfigFileName ); // make a backup of the config file QString backupDir = GetIbisAPI()->GetConfigDirectory() + "/BackupConfig/"; if( !QFile::exists( backupDir ) ) { QDir dir; dir.mkpath( backupDir ); } QString dateAndTime( QDateTime::currentDateTime().toString() ); QString backupFileName = QString( "%1Rev-%2-%3-%4" ).arg( backupDir ).arg( GetIbisAPI()->GetGitHashShort() ).arg( dateAndTime ).arg( info.fileName() ); InternalWriteHardwareConfig( backupFileName ); }
int main(void){ int *battery=malloc(2); initscr(); raw(); noecho(); halfdelay(100); printw("Battery: \n"); printw("Volume: \n"); printw("Date: \n"); while(1){ battery=batteryLevels(); mvprintw(0,9,"%3d%%+(%3d%%)",battery[0],battery[1]); //mvprintw(1,8,"%3d%%",getVolume()); mvprintw(2,7,"%s",dateAndTime()); refresh(); if(getch()=='q'){ break; } } endwin(); return 0; }