Ejemplo n.º 1
0
/*! Is called during directory traversal if a file was found.
 *
 *  \param absoluteFilePath the absolute path to the found file
 */
void ScanTraverser::onFile(const QString &absoluteFilePath)
{
    QFileInfo fileinfo(absoluteFilePath);

    countFile();
    countProcessed(fileinfo.size());
}
Ejemplo n.º 2
0
MT500::MT500(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MT500)
{
    log = true;
    if(log) MTLOG("MT500 Object Constructed");
    ui->setupUi(this);
    //Set program version here /////////
    progVer = "V.013";
    ////////////////////////////////////
    ui->versionLbl->setText("Program Version: " + progVer);
    ui->rxLabel->setText("Messages Transmitted: 0");
    initial = false;
    ui->ipTable->setColumnWidth(0, 120);
    getConfig();
    byteCount = 0;
    recordCnt = 0;
    cloudCnt = 0;
    setupRS232(COMin, COMout);
    initialCount = countFile("/home/administrator/Desktop/data.log");
    resetTimer = new QTimer(this);
    connect(resetTimer, SIGNAL(timeout()), this, SLOT(resetPorts()));
    validMsgTimer = new QTimer(this);
    connect(validMsgTimer, SIGNAL(timeout()), this, SLOT(clrBuf()));
    hbTimer = new QTimer(this);
    connect(hbTimer, SIGNAL(timeout()), this, SLOT(sendHB()));
    fipsTimer = new QTimer(this);
    connect(fipsTimer, SIGNAL(timeout()), this, SLOT(getFips()));
    msgCount = 0; //Does not include heartbeat messages
    getIPs();
    getFipsCounts();

    //
    // Initially we copy the current files to the previous file
    // directory so that we have something to compare to the first
    // time we sync the FIPS files
    //
    qDebug() << "Starting to copy...";
    //copyProc = new QProcess(this);
    QString oldDir = fipsDir + "old/";
    QString cmd = QString("cp %1*.dat %2").arg(fipsDir).arg(oldDir);
    system(cmd.toStdString().c_str());
    //copyParms << QString("%1*.dat").arg(fipsDir) << oldDir;
    //copyProc->start("cp", copyParms);
    //copyProc->waitForFinished(-1);
    //copyProc->terminate ();
    qDebug() << "Done copying...";

    for(int i = 0; i < 20; i++) {
        sockets[i] = new QTcpSocket(this);
    }
    if(log) MTLOG(QString("HB Interval: %1 min").arg(heartbeatInterval));
    if(log) MTLOG(QString("Fips Retrieval Interval: %1 min").arg(fipsInterval));
    hbTimer->start(heartbeatInterval*1000*60);
    fipsTimer->start(fipsInterval*60*1000);
    resetTimer->start(3600000 * 3); //Reset COM ports every 3 hours
    sendHB();
}
Ejemplo n.º 3
0
Archivo: main.c Proyecto: jvm3487/C
int main(int argc, char ** argv) {
  //WRITE ME (plus add appropriate error checking!)
  if (argc == 1){
    fprintf(stderr, "Please input a valid File!\n");
    exit (EXIT_FAILURE);
  }
  FILE * file1 = fopen(argv[1], "r");
  if (file1 == NULL){
      fprintf(stderr, "File does not exist!\n");
      exit (EXIT_FAILURE);
  }
  if (fclose(file1) != 0){
    fprintf(stderr, "Failed to close file!\n");
    exit (EXIT_FAILURE);
  }
//read the key/value pairs from the file named by argv[1] (call the result kv)
  kvarray_t * kvs = readKVs(argv[1]);
 //count from 2 to argc (call the number you count i)
  for (int i = 2; i < argc; i++) {
    //count the values that appear in the file named by argv[i], using kv as the key/value pair
    //   (call this result c)
    FILE * file2 = fopen(argv[i], "r");
    if (file2 == NULL){
      fprintf(stderr, "File does not exist!\n");
      exit (EXIT_FAILURE);
    }
    if (fclose(file2) != 0){
      fprintf(stderr, "Failed to close file!\n");
    }
    counts_t * c = countFile(argv[i], kvs);
    //compute the output file name from argv[i] (call this outName)
    char * outName = computeOutputFileName(argv[i]);

    //open the file named by outName (call that f)
    FILE * f = fopen(outName,"w");
    //print the counts from c into the FILE f
    printCounts(c,f);
    //close f
    fclose(f);
    //free the memory for outName and c
    free(outName);
    freeCounts(c);
  }
 //free the memory for kv
  freeKVs(kvs);
  return EXIT_SUCCESS;
}
Ejemplo n.º 4
0
int main(int argc, char ** argv) {
  int i;
  if(argc<=2)
    {
      fprintf(stderr,"The no. of inputs are less");
      return EXIT_FAILURE;
    }
  kvarray_t *kv=readKVs(argv[1]);
  if(kv->length==-1)
    {
      printf("Couldn't open file!");
      return EXIT_FAILURE;
    }
  if(kv->length==-2)
    {
      printf("Couldn't close file");
      return EXIT_FAILURE;
    }

  //WRITE ME (plus add appropriate error checking!)
 //read the key/value pairs from the file named by argv[1] (call the result kv)
  for(i=2;i<argc;i++) {
    counts_t *c=countFile(argv[i],kv); //count the values that appear in the file named by argv[i], using kv as the key/value pair
    //   (call this result c)
    char *outName = computeOutputFileName(argv[i]);//compute the output file name from argv[i] (call this outName)
    FILE *f = fopen(outName,"w");//open the file named by outName (call that f)
    printCounts(c,f);//print the counts from c into the FILE f
    if(fclose(f)!=0)
      {
	fprintf(stderr,"Couldn't close file!");
	return EXIT_FAILURE;
      }//close f
    free(outName);
    freeCounts(c); //free the memory for outName and c
    }
  freeKVs(kv); //free the memory for kv
  return EXIT_SUCCESS;
}