Beispiel #1
0
void testProgram()
{
	FILE *file1 = fopen("input.in", "r");
	FILE *file2 = fopen("output.data", "w");

	graph *G = loadGraph(file1);
	int **testcost = alocateMemoryForCost(G->noOfVertices);
	int *testpredecesors = allocateMemoryForPredecesors(G->noOfVertices);


	BellmanFord(G, 0, testcost, testpredecesors);
	for (int i = 0; i < G->noOfVertices; i++)
	{
		fprintf_s(file2, "%d\n", testcost[1][i]);
	}
	fclose(file1);
	fclose(file2);
	file1 = fopen("output.data", "r");
	file2 = fopen("result.txt", "r");

	if (compareFiles(file1, file2))
	{
		printf_s("Test succeded!\n");
	}
	else
	{
		printf_s("Test failed!\n");
	}

}
Beispiel #2
0
bool tryUpdateTraceServer (char const * origname, char const * runname)
{
	if (!fileExists(origname))
	{
		printf("launcher: Error: source file not present, nothing to do\n");
		return false;
	}
	if (!fileExists(runname))
	{
		printf("launcher: dest file not existing, copying...\n");
		tryCopyTraceServer(origname, runname);
		return false;
	}

	printf("launcher: both files exists, checking...\n");
	if (false == compareFiles(origname, runname))
	{
		printf("launcher: files differ!\n");
		return true;
	}
	else
	{
		printf("launcher: both files are up to date.\n");
		return false;
	}
}
Beispiel #3
0
void MainWindow::MenuEvents()
{
    this->connect(this->menu.load_img, SIGNAL(triggered()), this, SLOT(getFiles()));
    this->connect(this->menu.compare_img, SIGNAL(triggered()), this, SLOT(compareFiles()));
    this->connect(this->menu.exit, SIGNAL(triggered()), this, SLOT(close()));
    this->connect(this->menu.about, SIGNAL(triggered()), this, SLOT(aboutDialog()));
}
Beispiel #4
0
void
TestRun::test() {
    inputFilePath = KDESRCDIR "data/diagram.ppt";
    referenceDirPath = KDESRCDIR "data/diagram_odp/";
    const KoStore::Backend backend = KoStore::Tar;
    QBuffer buffer;
    convert(buffer, backend);
    qDebug() << buffer.isOpen();
    buffer.close();
    qDebug() << buffer.size();
    KoStore* input = KoStore::createStore(&buffer, KoStore::Read,
                                          KoOdf::mimeType(KoOdf::Presentation),
                                          backend);
    compareFiles(input, "content.xml");
    compareFiles(input, "styles.xml");
    compareFiles(input, "meta.xml");
    compareFiles(input, "settings.xml");
    compareFiles(input, "META-INF/manifest.xml");
}
void main(int argc, char* args[])
{
   int words;
   //char* iterate(hashtable *h);
   //clock_t start, end;
   double total;
   //int put(hashtable *h, char *string);
	if (argc < 2) {
	    printf("Please specify the names of the files!");
	    exit(1);
	}

	// get the filenames
	file0 = args[1];
	file1 = args[2];
	//start = clock();
    words = compareFiles(file0, file1);
	printf("The files have %d words in common\n", words);
        //end = clock();
        //total = (double)(end - start)/CLOCKS_PER_SEC;
        //printf("The total time is %fs\n",total);
}
Beispiel #6
0
void main() {
	int i;

	do{
		printf("1 to initialize txt file\n2 to compare\n3 to exit\n:");
		scanf("%d",&i);
		if(i==1){
			file1=fopen("gg.txt","w+");
			initFileList("./Galu",0,file1);
			fclose(file1);
		}else if(i==2){
			file1=fopen("gg.txt","r");
			file2=fopen("out.txt","w+");
			compareFiles("./Galu",0,file1);
			fclose(file1);
			fclose(file2);
			callInit();
		}else if(i==3){
			break;
		}
	}while(1);
}
Beispiel #7
0
bool MTest::saveCompareMimeData(QByteArray mimeData, const QString& saveName, const QString& compareWith)
      {
      saveMimeData(mimeData, saveName);
      return compareFiles(saveName, compareWith);
      }
Beispiel #8
0
bool MTest::saveCompareMusicXmlScore(Score* score, const QString& saveName, const QString& compareWith)
      {
      saveMusicXml(score, saveName);
      return compareFiles(saveName, compareWith);
      }
Beispiel #9
0
bool MTest::saveCompareScore(Score* score, const QString& saveName, const QString& compareWith) const
      {
      saveScore(score, saveName);
      return compareFiles(saveName, compareWith);
      }
Beispiel #10
0
void compareFiles(const char *name, int level,FILE *f){
    DIR *dir;
    struct dirent *ent;
	char path[1024]="";
	char t[ 512 ] = "";
	int len;

	struct stat b;


    if (!(dir = opendir(name))) return;
    if (!(ent = readdir(dir))) return;
    int i=0;
    do{
    	// if folder
        if (ent->d_type == DT_DIR){
            if(strcmp(ent->d_name,"chunkstempofolder")==0)continue;
			if(strcmp(ent->d_name,"..")==0) len = snprintf(path, sizeof(path)-1, "%s", name);
			else len = snprintf(path, sizeof(path)-1, "%s/%s", name, ent->d_name);
            path[len] = 0;

            if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue;
            compareFiles(path, level + 1,f);
        }
        //if file
        else{
        	len = snprintf(path, sizeof(path)-1, "%s", name);
        	//if(strcmp(ent->d_name,"a.c")!=0 && strcmp(ent->d_name,"a.out")!=0 && strcmp(ent->d_name,"sha1.c")!=0 && strcmp(ent->d_name,"sha1.h")!=0 && strcmp(ent->d_name,"out.txt")!=0 && strcmp(ent->d_name,"initFiles.txt")!=0) {
			strcpy(t,getLine(ent->d_name,f));
            printf("\n:%s/%s",path, ent->d_name);

			if(t!=NULL){
                char *sha;

                if(strstr(strrchr(ent->d_name, '.') , ".jpg")!=NULL || strstr(strrchr(ent->d_name, '.') , ".pdf")!=NULL || strstr(strrchr(ent->d_name, '.') , ".mkv")!=NULL || strstr(strrchr(ent->d_name, '.') , ".zip")!=NULL){
                    FILE *tempF, *jpgF;
                    char tempStr[strlen(path)+strlen(ent->d_name)+1];
                    char tempStr2[strlen(ent->d_name)+4];

                    strcpy(tempStr,path);
                    strcat(tempStr,"/");
                    strcat(tempStr,ent->d_name);
                    //printf("\n%s",tempStr);

                    jpgF=fopen(tempStr,"r");
                    strcat(tempStr,".txt");
                    tempF=fopen(tempStr,"w");

                    if(strstr(strrchr(ent->d_name, '.') , ".jpg")!=NULL) convertUTF8ToUnicode(jpgF, tempF,0);
                    while(!feof(jpgF)) convertUTF8ToUnicode(jpgF, tempF,1);
                    strcpy(tempStr2,ent->d_name);
                    strcat(tempStr2,".txt");
                    //strcat(t,getSha(path,tempStr2));
                    sha=getSha(path,tempStr2);
                    //printf("\n=====%s",getSha(path,tempStr2));
                    if(remove(tempStr)==0) /*printf("\nDeleted:%s",tempStr)*/;
                }else 

                sha=getSha(path,ent->d_name);//strcat(t, getSha(path,ent->d_name));

				if(strcmp(t,sha)!=0){
				char file[strlen(path)+strlen(ent->d_name)+1];

				// file path
				strcpy(file,path);
				strcat(file,"/");
                //strcat(file,"\"");
    			strcat(file,ent->d_name);
                //strcat(file,"\"");
    			strcpy(t, file);

    			strcat(t,"|");

    			// file hash
                strcat(t,sha);

				strcat(t,"|");

				// file size
				char buffer[18];
                //printf("\n%s is changed\n",file);

				sprintf(buffer, "%lu", getSize(file));
				strcat(t,buffer);
				strcat(t,"|");

                stat(file, &b);
				strftime(buffer, 100, "%m%d%Y-%H:%M:%S|", localtime(&b.st_ctime));
                //printf("\n%s\n",buffer);
				strcat(t,buffer);

				strftime(buffer, 100, "%m%d%Y-%H:%M:%S|", localtime(&b.st_mtime));
				strcat(t,buffer);

				strftime(buffer, 100, "%m%d%Y-%H:%M:%S", localtime(&b.st_atime));
				strcat(t,buffer);

				fprintf(file2, "%s\n",t);
				}
			}
        	//}	
        }

    } while (ent = readdir(dir));
    
    closedir(dir);
}
Beispiel #11
0
void compareFiles(const char *name, int level,FILE *f){
    DIR *dir;
    struct dirent *ent;
	char path[1024]="";
	char t[ 512 ] = "";
	int len;

	struct stat b;


    if (!(dir = opendir(name))) return;
    if (!(ent = readdir(dir))) return;
    int i=0;

    do{
    	// if folder
        if (ent->d_type == DT_DIR){
			if(strcmp(ent->d_name,"..")==0) len = snprintf(path, sizeof(path)-1, "%s", name);
			else len = snprintf(path, sizeof(path)-1, "%s/%s", name, ent->d_name);
            path[len] = 0;

            if (strcmp(ent->d_name, ".") == 0 || strcmp(ent->d_name, "..") == 0) continue;
            compareFiles(path, level + 1,f);
        }
        //if file
        else{
        	len = snprintf(path, sizeof(path)-1, "%s", name);
        	if(strcmp(ent->d_name,"a.c")!=0 && strcmp(ent->d_name,"a.out")!=0 && strcmp(ent->d_name,"sha1.c")!=0 && strcmp(ent->d_name,"sha1.h")!=0 && strcmp(ent->d_name,"out.txt")!=0 && strcmp(ent->d_name,"gg.txt")!=0) {
        			strcpy(t,getLine(ent->d_name,f));

        			// aaaaaa.txt bug
        			// if "a" is in file

        			if(t!=NULL){
        				if(strcmp(t,getSha(path,ent->d_name))!=0){
        					char file[strlen(path)+strlen(ent->d_name)+1];

        					// file path
        					strcpy(file,path);
        					strcat(file,"/");
                            //strcat(file,"\"");
		        			strcat(file,ent->d_name);
                            //strcat(file,"\"");
		        			strcpy(t, file);

		        			strcat(t,"|");

		        			// file hash
        					strcat(t, getSha(path,ent->d_name));

        					strcat(t,"|");

        					// file size
        					char buffer[18];
                            printf("\n%s is changed\n",file);
        					sprintf(buffer, "%lu", getSize(file));
        					strcat(t,buffer);
							strcat(t,"|");

                            stat(file, &b);
							strftime(buffer, 100, "%m%d%Y-%H:%M:%S|", localtime(&b.st_ctime));
                            //printf("\n%s\n",buffer);
							strcat(t,buffer);

							strftime(buffer, 100, "%m%d%Y-%H:%M:%S|", localtime(&b.st_mtime));
							strcat(t,buffer);

							strftime(buffer, 100, "%m%d%Y-%H:%M:%S", localtime(&b.st_atime));
							strcat(t,buffer);

        					fprintf(file2, "%s\n",t);
        				}
        			}

				
        	}	
        }

    } while (ent = readdir(dir));
    
    closedir(dir);
}
Beispiel #12
0
int cond::ValidateUtilities::execute(){

  initializeForDbConnection();
  std::string tag("");
  if( hasOptionValue("tag") ) tag = getOptionValue<std::string>("tag");
  std::string dir("");
  if( hasOptionValue("dir") ) dir = getOptionValue<std::string>("dir");

  bool debug = hasDebug();

  std::string refConnect = getOptionValue<std::string>("reference");
  std::string candidate = getOptionValue<std::string>("candidate" );

  std::tuple<std::string,std::string,std::string> connPars = persistency::parseConnectionString( refConnect );
  if( std::get<0>( connPars ) == "frontier" ) throwException("Cannot validate data from FronTier cache.","ValidateUtilities::execute");
     
  std::string refDbName = std::get<1>( connPars )+"_"+std::get<2>( connPars );
  
  if(debug){
    std::cout << "tag " << tag << std::endl;
  }  
  
  
  std::vector<std::string> tagToProcess;
  if( !tag.empty() ){
    tagToProcess.push_back( tag );
  } else {
    cond::DbSession refdb = openDbSession( "reference", cond::Auth::COND_READER_ROLE, true );
    refdb.transaction().start( true );
    cond::MetaData  metadata(refdb);
    metadata.listAllTags( tagToProcess );
    refdb.transaction().commit();
  }

  persistency::ConnectionPool connPool;
  std::cout <<"# Opening session on reference database..."<<std::endl;
  persistency::Session session0 = connPool.createSession( refConnect );
  std::cout <<"# Opening session on candidates database..."<<std::endl;
  persistency::Session session1 = connPool.createSession( candidate );
  session1.transaction().start();
  if( !session1.existsDatabase() ) throwException( "Candidate DB \""+candidate+" does not exist.",
						   "MigrateUtilities::execute" );

  std::cout <<"# "<<tagToProcess.size()<<" tag(s) to process."<<std::endl;
  std::cout <<std::endl;
  size_t nt = 0;
  size_t tid = 0;
  for( auto t : tagToProcess ){
    tid++;
    std::cout <<"--> Processing tag["<<tid<<"]: "<<t<<std::endl;
    std::string refFileName("");
    std::string candFileName("");
    try{      
      std::cout <<"    Writing reference db"<<std::endl;
      refFileName = writeTag( t, "ref", session0, dir );
      std::string destTag("");
      cond::MigrationStatus status;
      if( !session1.checkMigrationLog( refConnect, t, destTag, status ) ) {
	std::cout << "    ERROR: Tag "<< t <<" has not been migrated in database " << candidate <<std::endl;
	boost::filesystem::remove( boost::filesystem::path(refFileName) );
      } else {
	std::cout <<"    Writing candidate db"<<std::endl;
	candFileName = writeTag( destTag, "cand", session1, dir ); 
	bool cmp = compareFiles( refFileName, candFileName ); 
	if(!cmp){
	  std::cout <<"    ERROR: Comparison found differences."<<std::endl;
	  flushFile( refDbName, t, refFileName );
	  flushFile( refDbName, t, candFileName  );
	} else {
	  std::cout <<"    Comparison OK."<<std::endl;
	}
	nt++;
      }
    } catch ( const std::exception& e ){
      std::cout <<"    ERROR:"<<e.what()<<std::endl;
      std::cout <<"    Tag "<<t<<" will be skipped."<<std::endl;
    }
    cleanUp( refFileName );
    cleanUp( candFileName );
  }

  std::cout <<std::endl<<"# "<<nt<<" tag(s) checked for validation."<<std::endl;

  return 0;
}
Beispiel #13
0
int main(int argc, char **argv)
{
    appSetup(argc, argv);                       /* never returns on error */

    return compareFiles(&argv[arg_index]);
}