void EditFiles::viewModule(OovStringRef const fn, int lineNum) { FilePath moduleName(fn, FP_File); bool header = isCppHeader(fn); bool source = isCppSource(fn); if(header || source) { moduleName.appendExtension("h"); if(header) viewFile(moduleName, lineNum); else viewFile(moduleName, 1); moduleName.appendExtension("cpp"); if(source) viewFile(moduleName, lineNum); else viewFile(moduleName, 1); } else { viewFile(fn, lineNum); } }
// Return true while success. bool FindFiles::processFile(OovStringRef const filePath) { bool success = true; FilePath ext(filePath, FP_File); bool isSource = (isCppHeader(ext) || isCppSource(ext) || isJavaSource(ext)); if(mSourceFilesOnly ? isSource : true) { FILE *fp = fopen(filePath.getStr(), "r"); if(fp) { char buf[1000]; int lineNum = 0; while(fgets(buf, sizeof(buf), fp)) { lineNum++; char const *match=NULL; if(mCaseSensitive) { match = strstr(buf, mSrchStr.c_str()); } else { match = strcasestr(buf, mSrchStr.c_str()); } if(match) { mNumMatches++; OovString matchStr = filePath; matchStr += ':'; matchStr.appendInt(lineNum); matchStr += " "; matchStr += buf; // matchStr += '\n'; Gui::appendText(mView, matchStr); } } fclose(fp); } } return success; }