QStringList FSWatcher::getFSmountpoints() { //output line format: name::filesystem::totalspace::usedspace::percent // -- sizes all in K QStringList output; //ZFS Checks QStringList zpools = runCMD("zpool list -o name"); if(zpools.length() > 1) { //Then there are ZFS pools available for(int i=1; i<zpools.length(); i++) { //skip the header line QStringList tmp = runCMD("zfs list -o available,used "+zpools[i]); //second line contains the data QString avail = tmp[1].section(" ",0,0,QString::SectionSkipEmpty); QString used = tmp[1].section(" ",1,1,QString::SectionSkipEmpty); double iUsed = floor(displayToDouble(used)); double iTotal = floor(displayToDouble(avail)) + iUsed; int percent = calculatePercentage(iUsed, iTotal); //qDebug() << "Percent calc: tot:"<<iTotal<<"used"<<iUsed<<"percent"<<percent; //format the output string and add it in output << zpools[i]+"::zfs::"+QString::number(iTotal)+"::"+QString::number(iUsed)+"::"+QString::number(percent); } } //Now get all the rest of the mounted filesystems QStringList dfout = runCMD("df -h -T"); //Format: name, filesystem, size, used, available, percent, mountpoint for(int i=1; i<dfout.length(); i++) { //ignore certain filesystems if(dfout[i].startsWith("devfs")) {} else if(dfout[i].startsWith("procfs")) {} else if(dfout[i].startsWith("linprocfs")) {} else if(dfout[i].startsWith("linsysfs")) {} else if(dfout[i].startsWith("fdescfs")) {} else { //Now parse out the info dfout[i].replace("\t"," "); QString fs = dfout[i].section(" ",1,1,QString::SectionSkipEmpty).simplified(); if(fs != "zfs" && fs!="cd9660" && fs!="nullfs" && fs!="fusefs") { //ignore zfs filesystems (already taken care of) QString name = dfout[i].section(" ",6,6,QString::SectionSkipEmpty).simplified(); QString total = dfout[i].section(" ",2,2,QString::SectionSkipEmpty).simplified(); QString used = dfout[i].section(" ",3,3,QString::SectionSkipEmpty).simplified(); //Calculate the percent double iUsed = displayToDouble(used); double iTotal = displayToDouble(total); int percent = calculatePercentage(iUsed, iTotal); //qDebug() << "df Item:" << dfout[i]; //qDebug() << " - Detected:" << name << fs << iTotal << iUsed << percent; //format the output string and add it in output << name+"::"+fs+"::"+QString::number(iTotal)+"::"+QString::number(iUsed)+"::"+QString::number(percent); } } } //Return the results //qDebug() << "FS output:" << output; return output; }
int main(int argc, char *argv[]) { int EXAMS_TOTAL = 2; FILE * fin = NULL; char * name = NULL; double weightedAvg, gpa; int assignmentsTotal, labsTotal, quizzesTotal; int * assignments = NULL, *labs = NULL, *quizzes = NULL, exams[EXAMS_TOTAL], finalExam; double assignmentsPercentage, labsPercentage, quizzesPercentage, examsPercentage, finalPercentage; if(argc == 2) fin = openFileNoPrompt(argv[1]); do { if(fin == NULL) fin = openFilePrompt(); name = readName(fin); assignments = createAndFillArray(&assignmentsTotal, fin); labs = createAndFillArray(&labsTotal, fin); quizzes = createAndFillArray(&quizzesTotal, fin); fillArray(exams, fin); finalExam = readFinalScore(fin); fclose(fin); fin = NULL; assignmentsPercentage = calculatePercentage(assignments, assignmentsTotal, 100, .25); labsPercentage = calculatePercentage(labs, labsTotal, 50, .20); quizzesPercentage = calculatePercentage(quizzes, quizzesTotal, 25, .05); examsPercentage = calculatePercentage(exams, EXAMS_TOTAL, 100, .30); finalPercentage = calculatePercentage(&finalExam, 1, 200, .20); displayCategoryPercentage(assignmentsPercentage, labsPercentage, quizzesPercentage, examsPercentage, finalPercentage); weightedAvg = calcWeightedAvg(assignmentsPercentage, labsPercentage, quizzesPercentage, examsPercentage, finalPercentage); gpa = calcGPA(weightedAvg); displayGrade(name, weightedAvg, gpa); clean(name); cleanUp(assignments); cleanUp(labs); cleanUp(quizzes); assignments = labs = quizzes = NULL; name = NULL; }while(goAgain()); return 0; }// end main
bool CCInterpolatorSin2Curve::update(const float delta) { updating = false; if( current != NULL ) { if( incrementAmount( delta ) ) { const float percentage = calculatePercentage(); updateInterpolation( percentage ); updating = true; return true; } else if( *current != target ) { *current = target; current = NULL; updating = true; return true; } else { current = NULL; } } else if( onInterpolated.length > 0 ) { CCLAMBDA_SIGNAL pendingCallbacks; for( int i=0; i<onInterpolated.length; ++i ) { pendingCallbacks.add( onInterpolated.list[i] ); } onInterpolated.length = 0; CCLAMBDA_EMIT_ONCE( pendingCallbacks ); } return updating; }