void Cursynth::startLoad() { // Store all patche names from system and user patch directories. patches_ = getAllFiles(PATCHES_DIRECTORY, EXTENSION); std::vector<std::string> user_patches = getAllFiles(getUserPatchesPath(), EXTENSION); patches_.insert(patches_.end(), user_patches.begin(), user_patches.end()); if (patches_.size() == 0) return; // Start patch loading by loading last patch browsed. state_ = PATCH_LOADING; patch_load_index_ = std::min<int>(patch_load_index_, patches_.size() - 1); loadFromFile(patches_[patch_load_index_]); }
void initProgram() { bdoRootFolder = oneLevelDown(getCurrentPath()); if (!backupExists()) { createBackup(); } printf("\nCounting files...\n\n"); // Counts how many files there is in the "files_to_patch" folder assigns to filesToPatchCount, // and get all the file names in folders and sub folders and returns them as an array of strings char** fileNames = getAllFiles(FILES_TO_PATCH_FOLDER_NAME,"*",&filesToPatchCount); if (filesToPatchCount == 0) { printf("No files present in %s\n\n",FILES_TO_PATCH_FOLDER_NAME); system("PAUSE"); exit(1); } printf("%ld files were found in %s\n\n", filesToPatchCount, FILES_TO_PATCH_FOLDER_NAME); filesToPatch = (FileToPatch*)malloc(filesToPatchCount * sizeof(FileToPatch)); long i = 0; for (i = 0; i < filesToPatchCount; i++) { filesToPatch[i].fileName = fileNames[i]; filesToPatch[i].patched = 0; } }
QVector<QString> FileUtils::getAllFiles(const QString &path) { QVector<QString> result; QDir dir(path); QFileInfoList fileInfoLists = dir.entryInfoList(); QFileInfoList::const_iterator iterator = fileInfoLists.constBegin(); for(; iterator != fileInfoLists.constEnd(); iterator++) { QString filename = iterator->fileName(); if (!filename.startsWith(".")) { if (iterator->isDir()) { result += getAllFiles(iterator->absoluteFilePath()); } else if (iterator->isFile()) { result.push_back(iterator->absoluteFilePath()); } else { // } } } return result; }
char* xfs_cli_file_gen (const char *text, int state) { static int i, j, len; static XOSFILE *files; char *result = NULL; XOSFILE *next; if (state == 0) { xfs_cli_destroy_file_list (files); files = getAllFiles(); len = strlen(text); } while (files) { if (!strncmp(text, files->name, len)) { result = strdup(files->name); } next = files->next; free(files->name); free(files); files = next; if (result) break; } return result; }
int DicomImageSet::parseFolder(QString folderName) { QStringList fileList = getAllFiles(folderName); HRESULT hr = CoInitialize(NULL); if (!SUCCEEDED(hr)) { return NULL; } hr = S_OK; IXMLDOMDocument *pXMLDom = NULL; IXMLDOMElement *pRoot = NULL; BSTR bstrXML = NULL; VARIANT varFileName; VariantInit(&varFileName); QProgressDialog progress (QString("Parsing all files in %1").arg(folderName), QString("Cancel"), 0, fileList.count()); CHK_HR(CreateAndInitDOM(&pXMLDom)); // Create a processing instruction element. CHK_HR(CreateAndAddPINode(pXMLDom, L"xml", L"version='1.0'")); // Create the root element. CHK_HR(CreateElement(pXMLDom, L"root", &pRoot)); // Create an attribute for the <root> element, with name "created" and value "using dom". CHK_HR(CreateAndAddAttributeNode(pXMLDom, L"path", folderName.toStdWString().c_str(), pRoot)); // Add NEWLINE for identation before </root>. CHK_HR(CreateAndAddTextNode(pXMLDom, L"\n", pRoot)); // add <root> to document CHK_HR(AppendChildToParent(pRoot, pXMLDom)); progress.show(); for (int i=0; i<fileList.count(); ++i) { insertFileItem(pXMLDom, pRoot, folderName, fileList[i]); progress.setValue(i); } CHK_HR(VariantFromString(QDir(folderName).filePath(DATASET_FILE_NAME).toStdWString().c_str(), varFileName)); CHK_HR(pXMLDom->save(varFileName)); CleanUp: SAFE_RELEASE(pRoot); SysFreeString(bstrXML); VariantClear(&varFileName); CoUninitialize(); if (FAILED(hr)) { SAFE_RELEASE(pXMLDom); return 0; } return 1; }
TEST(JSONCompilationDatabase, GetAllFiles) { std::string ErrorMessage; EXPECT_EQ(std::vector<std::string>(), getAllFiles("[]", ErrorMessage)) << ErrorMessage; std::vector<std::string> expected_files; SmallString<16> PathStorage; llvm::sys::path::native("//net/dir/file1", PathStorage); expected_files.push_back(PathStorage.str()); llvm::sys::path::native("//net/dir/file2", PathStorage); expected_files.push_back(PathStorage.str()); EXPECT_EQ(expected_files, getAllFiles( "[{\"directory\":\"//net/dir\"," "\"command\":\"command\"," "\"file\":\"file1\"}," " {\"directory\":\"//net/dir\"," "\"command\":\"command\"," "\"file\":\"file2\"}]", ErrorMessage)) << ErrorMessage; }
TEST_F(FSTestFixture, getAllFiles_without_extsFilter) { std::vector<Path> content; std::vector<Path> content0; Path path(getTestDirectory().string(), "", false); Path path0((getTestDirectory() / "0").string(), "", false); getAllFiles(path, content, nullptr); getAllFiles(path0, content0, nullptr); ASSERT_EQ(content.size(), 0); ASSERT_EQ(content0.size(), 4); ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / "0").string(), "", true), content0)); ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / "1.txt").string(), "", true), content0)); ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / "2.png").string(), "", true), content0)); ASSERT_TRUE(isInVector(Path((getTestDirectory() / "0" / UNICODE_EXAMPLE_FILE).string(), "", true), content0)); }
TEST_F(FSTestFixture, getAllFiles_with_extsfiler) { std::vector<Path> content; std::vector<std::string> filter; filter.push_back("txt"); Path path((getTestDirectory() / "0").string(), "", false); getAllFiles(path, content, &filter); ASSERT_EQ(content.size(), 1); ASSERT_EQ(content[0].getFullPath(), (getTestDirectory() / "0" / "1.txt").string()); }
WINEXPORT BOOL CALLBACK GrepListProc( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam ) { static char **fileList; static int fileCount; HWND list_box; char tmp[MAX_STR]; WORD cmd; switch( msg ) { case WM_INITDIALOG: list_box = GetDlgItem( dlg, ID_FILE_LIST ); SendMessage( list_box, WM_SETFONT, (WPARAM)FontHandle( dirw_info.text.font ), 0L ); MySprintf( tmp, "Files Containing \"%s\"", sString ); SetWindowText( dlg, tmp ); fileList = (char **)MemAlloc( sizeof( char * ) * MAX_FILES ); fileCount = initList( list_box, (char *)lparam, fileList ); if( fileCount == 0 ) { /* tell him that there are no matches and close down? */ Message1( "String \"%s\" not found", sString ); EndDialog( dlg, DO_NOT_CLEAR_MESSAGE_WINDOW ); } else { SendMessage( list_box, LB_SETCURSEL, 0, 0L ); BringWindowToTop( dlg ); SetFocus( dlg ); } break; case WM_COMMAND: cmd = LOWORD( wparam ); switch( cmd ) { case ID_FILE_LIST: if( GET_WM_COMMAND_CMD( wparam, lparam ) == LBN_DBLCLK ) { getOneFile( dlg, fileList, &fileCount, TRUE ); } break; case ID_EDIT: case ID_GOTO: getOneFile( dlg, fileList, &fileCount, cmd == ID_GOTO ); break; case ID_GETALL: getAllFiles( dlg, fileList, &fileCount ); break; case IDCANCEL: EndDialog( dlg, ERR_NO_ERR ); return( TRUE ); } break; case WM_DESTROY: MemFreeList( fileCount, fileList ); break; } return( FALSE ); } /* GrepListProc */
void testListingFiles(){ RuntimeErrorValidator * validator = buildErrorSuccessValidator(); List l = getAllFiles("VDA1", validator); if(hasError(validator)){ error(validator->errorDescription); return ; } Iterator * ite = buildIterator(l); char * element = NULL; while( hasMoreElements(ite)){ element = next(ite); info( concatAll(4, "Archivo: " , element , " con tamaño: " , ltoa(getCurrentFileSize("VDA1" , element , validator)))); } }
QStringList DicomImageSet::getAllFiles(const QString &folderName) { QDir folder (folderName); QFileInfoList fileInfoList = folder.entryInfoList(); QStringList fileList; for (int i=0; i<fileInfoList.count(); ++i) { QString fName = fileInfoList[i].fileName(); if (!fileInfoList[i].isDir()) { fileList.append(fileInfoList[i].absoluteFilePath()); } else if (fileInfoList[i].fileName().compare (".") && fileInfoList[i].fileName().compare ("..")) { fileList = fileList + getAllFiles(fileInfoList[i].absoluteFilePath()); } } return fileList; }
WINEXPORT BOOL CALLBACK GrepListProc95( HWND dlg, UINT msg, WPARAM wparam, LPARAM lparam ) { static char **fileList; static int fileCount; HWND list_box; char tmp[MAX_STR]; WORD cmd; LVCOLUMN lvc; LVITEM lvi; RECT rc; switch( msg ) { case WM_INITDIALOG: list_box = GetDlgItem( dlg, ID_FILE_LIST ); SendMessage( list_box, WM_SETFONT, (WPARAM)FontHandle( dirw_info.text.font ), 0L ); MySprintf( tmp, "Files Containing \"%s\"", sString ); SetWindowText( dlg, tmp ); rc.left = 0; rc.right = 70; MapDialogRect( dlg, &rc ); lvc.mask = LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; lvc.cx = rc.right; lvc.pszText = "File Name"; lvc.iSubItem = 0; SendMessage( list_box, LVM_INSERTCOLUMN, 0, (LPARAM)&lvc ); lvc.cx = rc.right * 3; lvc.pszText = "Line"; lvc.iSubItem = 1; SendMessage( list_box, LVM_INSERTCOLUMN, 1, (LPARAM)&lvc ); fileList = (char **)MemAlloc( sizeof( char * ) * MAX_FILES ); fileCount = initList( list_box, (char *)lparam, fileList ); if( fileCount == 0 ) { Message1( "String \"%s\" not found", sString ); EndDialog( dlg, DO_NOT_CLEAR_MESSAGE_WINDOW ); } else { lvi.stateMask = LVIS_SELECTED; lvi.state = LVIS_SELECTED; SendMessage( list_box, LVM_SETITEMSTATE, 0, (LPARAM)&lvi ); BringWindowToTop( dlg ); SetFocus( dlg ); } break; case WM_COMMAND: cmd = LOWORD( wparam ); switch( cmd ) { case ID_EDIT: case ID_GOTO: getOneFile( dlg, fileList, &fileCount, cmd == ID_GOTO ); break; case ID_GETALL: getAllFiles( dlg, fileList, &fileCount ); break; case IDCANCEL: EndDialog( dlg, ERR_NO_ERR ); return( TRUE ); } break; case WM_NOTIFY: if( ((NMHDR *)lparam)->code == NM_DBLCLK ) { getOneFile( dlg, fileList, &fileCount, TRUE ); } break; case WM_DESTROY: MemFreeList( fileCount, fileList ); break; } return( FALSE ); } /* GrepListProc95 */
void compareWithOneSample(char* sample) { HImage imgOrg, imgCmp; TFacePosition fpOrg, fpCmp; FSDK_FaceTemplate ftOrg, ftCmp; int result; float similarity = 0.0f, maxSim = 0.0f; char *pair = NULL; char *temp; int nFile; char **pics; std::ofstream fileOut; fileOut.open("BadPicsPair.txt"); pics = getAllFiles(nFile); initFaceSDK(); /* set detection parameters first param : set comparing rotation ratio true == -30 ~ 30 degree, false == -15 ~ 15 second param : get twisted ratio true == get , false == not get third param : set internal resize ratio */ FSDK_SetFaceDetectionParameters(false, false, 500); for(int i = 0 ; i < nFile ; ++i) { if(!strcmp(pics[i] + strlen("./Pics/"), sample)) { temp = pics[0]; pics[0] = pics[i]; pics[i] = temp; break; } } result = FSDK_LoadImageFromFile(&imgOrg, pics[0]); if(result != FSDKE_OK) { std::cout<<"============= Input Sample is Bad ============"<<std::endl<<std::endl; return; } result = FSDK_DetectFace(imgOrg, &fpOrg); if(result != FSDKE_OK) { std::cout<<"============= Input Sample is Bad ============"<<std::endl<<std::endl; return; } result = FSDK_GetFaceTemplateInRegion(imgOrg, &fpOrg, &ftOrg); if(result != FSDKE_OK) { std::cout<<"============= Input Sample is Bad ============"<<std::endl<<std::endl; return; } for(int i = 1 ; i < nFile ; ++i) { //std::cout<<"=================== This pair ===================="<<std::endl; //std::cout<<pics[i]<<" "<<pics[j]<<std::endl<<std::endl; // load 1 imgs result = FSDK_LoadImageFromFile(&imgCmp, pics[i]); //std::cout<<"=================== Load Image ==================="<<std::endl; //std::cout<<ErrorCode[-result1]<<std::endl<<std::endl; // find faces result = FSDK_DetectFace(imgCmp, &fpCmp); if(result != FSDKE_OK) { std::cout<<"============= break this comparison ============="<<std::endl<<std::endl; if(result != FSDKE_OK) fileOut<<pics[i]<<std::endl; FSDK_FreeImage(imgCmp); break; } //std::cout<<"=================== Find Faces ==================="<<std::endl; //std::cout<<ErrorCode[-result1]<<std::endl<<std::endl; FSDK_GetFaceTemplateInRegion(imgCmp, &fpCmp, &ftCmp); if(result != FSDKE_OK) { std::cout<<"============= break this comparison ============="<<std::endl; std::cout<<pics[i]<<std::endl<<std::endl; FSDK_FreeImage(imgCmp); break; } FSDK_MatchFaces(&ftOrg, &ftCmp, &similarity); std::cout<<"=================== Similarity =================="<<std::endl; std::cout<<"Similarity is "<<similarity * 100<<"%"<<std::endl<<std::endl; if(similarity >= maxSim) { maxSim = similarity; if(pair != NULL) { delete[] pair; pair = NULL; } pair = new char[strlen(pics[i]) + 1]; strcpy(pair, pics[i]); } FSDK_FreeImage(imgCmp); } FSDK_FreeImage(imgOrg); std::cout<<"===================== Result ===================="<<std::endl; std::cout<<"Total "<<nFile<<" files"<< std::endl; std::cout<<"Max Similarity: "<<maxSim* 100<<"%"<<std::endl; std::cout<<pics[0]<<std::endl; std::cout<<pair<<std::endl; for(int i = 0 ; i < nFile ; ++i) delete[] pics[i]; delete[] pics; delete[] pair; fileOut.close(); getchar(); }
void compareAllSample() { HImage imgOrg, imgCmp; TFacePosition fpOrg, fpCmp; FSDK_FaceTemplate ftOrg, ftCmp; int result1, result2; float similarity = 0.0f, maxSim = 0.0f; char *pair1 = NULL, *pair2 = NULL; int nFile; char **pics; std::ofstream fileOut; fileOut.open("BadPicsPair.txt"); pics = getAllFiles(nFile); initFaceSDK(); /* set detection parameters first param : set comparing rotation ratio true == -30 ~ 30 degree, false == -15 ~ 15 second param : get twisted ratio true == get , false == not get third param : set internal resize ratio */ FSDK_SetFaceDetectionParameters(false, false, 500); for(int i = 0 ; i < nFile - 1; ++i) { for(int j = i + 1 ; j < nFile ; ++j) { //std::cout<<"=================== This pair ===================="<<std::endl; //std::cout<<pics[i]<<" "<<pics[j]<<std::endl<<std::endl; // load 2 imgs result1 = FSDK_LoadImageFromFile(&imgOrg, pics[i]); result2 = FSDK_LoadImageFromFile(&imgCmp, pics[j]); //std::cout<<"=================== Load Image ==================="<<std::endl; //std::cout<<ErrorCode[-result1]<<std::endl; //std::cout<<ErrorCode[-result2]<<std::endl<<std::endl; // find faces result1 = FSDK_DetectFace(imgOrg, &fpOrg); result2 = FSDK_DetectFace(imgCmp, &fpCmp); if(result1 != FSDKE_OK || result2 != FSDKE_OK) { std::cout<<"============= break this comparation ============="<<std::endl<<std::endl; if(result1 != FSDKE_OK) fileOut<<pics[i]<<std::endl; if(result2 != FSDKE_OK) fileOut<<pics[j]<<std::endl; FSDK_FreeImage(imgOrg); FSDK_FreeImage(imgCmp); break; } //std::cout<<"=================== Find Faces ==================="<<std::endl; //std::cout<<ErrorCode[-result1]<<std::endl; //std::cout<<ErrorCode[-result2]<<std::endl<<std::endl; FSDK_GetFaceTemplateInRegion(imgOrg, &fpOrg, &ftOrg); FSDK_GetFaceTemplateInRegion(imgCmp, &fpCmp, &ftCmp); if(result1 != FSDKE_OK || result2 != FSDKE_OK) { std::cout<<"============= break this comparation ============="<<std::endl; std::cout<<pics[i]<<" "<<pics[j]<<std::endl<<std::endl; FSDK_FreeImage(imgOrg); FSDK_FreeImage(imgCmp); break; } FSDK_MatchFaces(&ftOrg, &ftCmp, &similarity); std::cout<<"=================== Similarity ==================="<<std::endl; std::cout<<"Similarity is "<<similarity * 100<<"%"<<std::endl<<std::endl; if(similarity >= maxSim) { maxSim = similarity; if(pair1 != NULL && pair2 != NULL) { delete[] pair1; delete[] pair2; pair1 = NULL; pair2 = NULL; } pair1 = new char[strlen(pics[i]) + 1]; pair2 = new char[strlen(pics[j]) + 1]; strcpy(pair1, pics[i]); strcpy(pair2, pics[j]); } FSDK_FreeImage(imgOrg); FSDK_FreeImage(imgCmp); } } std::cout<<"===================== Result ====================="<<std::endl; std::cout<<"Total "<<nFile<<" files"<< std::endl; std::cout<<"Max Similarity: "<<maxSim* 100<<"%"<<std::endl; std::cout<<pair1<<std::endl; std::cout<<pair2<<std::endl; for(int i = 0 ; i < nFile ; ++i) delete[] pics[i]; delete[] pics; delete[] pair1; delete[] pair2; fileOut.close(); getchar(); }
void addToVector(std::string event_name) { int timestamp; timestamp=getTimestamp(event_name); getAllFiles(); if(event_name.compare(0,14,drpc)==0) { std::cerr << "File starts with 'DRPC' string." << std::endl; //Check to make sure you actually have the smallest timestamp if(timestamp<=drpc_min) { std::cerr << "The file also has the lowest timestamp for drpc." << std::endl; //Guarantees that all the elements in the vector have the same timestamp if(DR_DRAssembler_START.empty()) { dr_hist_timestamp = timestamp; DR_DRAssembler_START.push_back(event_name); processHist(DR_DRAssembler_START,max_size); } else if(timestamp==dr_hist_timestamp) { DR_DRAssembler_START.push_back(event_name); processHist(DR_DRAssembler_START,max_size); } else { DR_DRAssembler_START.clear(); dr_hist_timestamp = timestamp; DR_DRAssembler_START.push_back(event_name); processHist(DR_DRAssembler_START,max_size); } } } else if(event_name.compare(0,12,fepc1)==0) { std::cerr << "File starts with 'FEPC1' string." << std::endl; //Check to make sure you actually have the smallest timestamp if(timestamp<=fepc1_min) { std::cerr << "The file also has the lowest timestamp for fepc1." << std::endl; //Guarantees that all the elements in the vector have the same timestamp if(FE1_RATAssembler_START.empty()) { fe1_hist_timestamp=timestamp; FE1_RATAssembler_START.push_back(event_name); processHist(FE1_RATAssembler_START,max_size); } else if(timestamp==fe1_hist_timestamp) { FE1_RATAssembler_START.push_back(event_name); processHist(FE1_RATAssembler_START,max_size); } else { FE1_RATAssembler_START.clear(); fe1_hist_timestamp = timestamp; FE1_RATAssembler_START.push_back(event_name); processHist(FE1_RATAssembler_START,max_size); } } } else if(event_name.compare(0,12,fepc2)==0) { std::cerr << "File starts with 'FEPC2' string." << std::endl; if(timestamp<=fepc2_min) { std::cerr << "The file also has the lowest timestamp for fepc2." << std::endl; //Guarantees that all the elements in the vector have the same timestamp if(FE2_RATAssembler_START.empty()) { fe2_hist_timestamp=timestamp; FE2_RATAssembler_START.push_back(event_name); processHist(FE2_RATAssembler_START,max_size); } else if(timestamp==fe2_hist_timestamp) { FE2_RATAssembler_START.push_back(event_name); processHist(FE2_RATAssembler_START,max_size); } else { FE2_RATAssembler_START.clear(); fe2_hist_timestamp = timestamp; FE2_RATAssembler_START.push_back(event_name); processHist(FE2_RATAssembler_START,max_size); } } } else if(event_name.compare(0,12,fepc3)==0) { std::cerr << "File starts with 'FEPC3' string." << std::endl; if(timestamp<=fepc3_min) { std::cerr << "The file also has the lowest timestamp for fepc3." << std::endl; //Guarantees that all the elements in the vector have the same timestamp if(FE3_RATAssembler_START.empty()) { fe3_hist_timestamp=timestamp; FE3_RATAssembler_START.push_back(event_name); processHist(FE3_RATAssembler_START,max_size); } else if(fe3_hist_timestamp==timestamp) { FE3_RATAssembler_START.push_back(event_name); processHist(FE3_RATAssembler_START,max_size); } else { FE3_RATAssembler_START.clear(); fe3_hist_timestamp = timestamp; FE3_RATAssembler_START.push_back(event_name); processHist(FE3_RATAssembler_START,max_size); } } } else if(event_name.compare(0,12,fepc4)==0) { std::cerr << "File starts with 'FEPC4' string." << std::endl; if(timestamp<=fepc4_min) { std::cerr << "The file also has the lowest timestamp for fepc4." << std::endl; //Guarantees that all the elements in the vector have the same timestamp if(FE4_RATAssembler_START.empty()) { fe4_hist_timestamp=timestamp; FE4_RATAssembler_START.push_back(event_name); processHist(FE4_RATAssembler_START,max_size); } else if(timestamp==fe4_hist_timestamp) { FE4_RATAssembler_START.push_back(event_name); processHist(FE4_RATAssembler_START,max_size); } else { FE4_RATAssembler_START.clear(); fe4_hist_timestamp = timestamp; FE4_RATAssembler_START.push_back(event_name); processHist(FE4_RATAssembler_START,max_size); } } } };
int main(int argc, char *argv[]) { std::vector<std::string> args(argv + 1, argv + argc); if (args.size() < 1 || (args.size() > 1 && args[1] != "--")) { utils::generateUsageStr(); return -1; } const std::string path(args[0]); const std::string json("compile_commands.json"); // Load compile commands auto db = utils::loadDB(path + json); if (!db) { utils::generateUsageStr(); return -1; } ct::ClangTool tool(*db, db->getAllFiles()); // Pass compiler options if (args.size() > 2) { std::vector<std::string> compilerArgs(args.begin() + 2, args.end()); ct::ArgumentInsertPosition pos = ct::ArgumentInsertPosition::END; tool.appendArgumentsAdjuster(ct::getInsertArgumentAdjuster(compilerArgs, pos)); } // Add matchers ca::MatchFinder finder; std::string pathRegex(path + "*"); match::SimpleMatcher functionHandler; match::Matcher<clang::IfStmt> ifHandler; match::Matcher<clang::ForStmt> forHandler; match::Matcher<clang::CXXForRangeStmt> rangeHandler; match::Matcher<clang::WhileStmt> whileHandler; match::Matcher<clang::DoStmt> doHandler; match::Matcher<clang::CaseStmt> caseHandler; match::Matcher<clang::CXXCatchStmt> catchHandler; match::Matcher<clang::BinaryOperator> binaryOpHandler; match::Matcher<clang::ConditionalOperator> condOpHandler; match::Matcher<clang::BinaryConditionalOperator> binaryCondOpHandler; finder.addMatcher(match::getMatcher<clang::FunctionDecl>(pathRegex), &functionHandler); finder.addMatcher(match::getMatcher<clang::IfStmt>(pathRegex), &ifHandler); finder.addMatcher(match::getMatcher<clang::ForStmt>(pathRegex), &forHandler); finder.addMatcher(match::getMatcher<clang::CXXForRangeStmt>(pathRegex), &rangeHandler); finder.addMatcher(match::getMatcher<clang::WhileStmt>(pathRegex), &whileHandler); finder.addMatcher(match::getMatcher<clang::DoStmt>(pathRegex), &doHandler); finder.addMatcher(match::getMatcher<clang::CaseStmt>(pathRegex), &caseHandler); finder.addMatcher(match::getMatcher<clang::CXXCatchStmt>(pathRegex), &catchHandler); finder.addMatcher(match::getMatcher<clang::BinaryOperator>(pathRegex), &binaryOpHandler); finder.addMatcher(match::getMatcher<clang::ConditionalOperator>(pathRegex), &condOpHandler); finder.addMatcher(match::getMatcher<clang::BinaryConditionalOperator>(pathRegex), &binaryCondOpHandler); // Run tool int rc = tool.run(ct::newFrontendActionFactory(&finder).get()); if (rc) { utils::generateUsageStr(); return -1; } // Output results std::ofstream output; output.open("results.txt"); if (!output.is_open()) { std::cerr << "Error while opening file for writing\n"; return -1; } output << "Path\tLine\tColumn\tName\tSignature\tLOC\tCyclomaticN\n"; auto stats = match::MatcherBase::getStats(); for (auto it = stats.begin(); it != stats.end(); ++it) { output << it->first.path << "\t" << it->first.line << "\t" << it->first.column << "\t" << it->first.name << "\t" << it->first.signature << "\t" << it->second.loc << "\t" << it->second.cyclomaticN << "\n"; } return 0; }
int main(){ getAllFiles(); char *file = "boo"; openFile(file); return 0; }