本文整理汇总了C++中SafeBuf::fillFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ SafeBuf::fillFromFile方法的具体用法?C++ SafeBuf::fillFromFile怎么用?C++ SafeBuf::fillFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SafeBuf
的用法示例。
在下文中一共展示了SafeBuf::fillFromFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sendPageThesaurus
//.........这里部分代码省略.........
"error reloading thesaurus data"
"</font></b></center>");
}
}
long manualAddLen = 0;
char *manualAdd = NULL;
SafeBuf manualAddBuf;
if ((manualAdd = r->getString("manualadd", &manualAddLen))) {
trimWhite(manualAdd);
manualAddLen = gbstrlen(manualAdd);
File manualFile;
manualFile.set(g_hostdb.m_dir, "dict/thesaurus-manual.txt");
if (manualFile.open(O_WRONLY | O_CREAT | O_TRUNC) &&
(manualFile.write(manualAdd, manualAddLen, 0) ==
manualAddLen)) {
char newl = '\n'; // for write()
if (manualAdd[manualAddLen-1] != '\n')
manualFile.write(&newl, 1, manualAddLen);
p.safePrintf(
"<center><b><font color=#ff0000>"
"updated manual add file sucessfully"
"</font></b></center>");
} else {
p.safePrintf(
"<center><b><font color=#ff0000>"
"error writing manual add file"
"</font></b></center>");
}
} else {
char ff[PATH_MAX];
snprintf(ff, PATH_MAX, "%sdict/thesaurus-manual.txt",
g_hostdb.m_dir);
if (manualAddBuf.fillFromFile(ff)) {
if (*(manualAddBuf.getBuf()-1) != '\n')
manualAddBuf.pushChar('\n');
manualAdd = manualAddBuf.getBufStart();
manualAddLen = manualAddBuf.length();
}
}
long affinityAddLen = 0;
char *affinityAdd = NULL;
SafeBuf affinityAddBuf;
if ((affinityAdd = r->getString("affinityadd", &affinityAddLen))) {
trimWhite(affinityAdd);
affinityAddLen = gbstrlen(affinityAdd);
File affinityFile;
affinityFile.set(g_hostdb.m_dir,
"dict/thesaurus-affinity.txt");
if (affinityFile.open(O_WRONLY | O_CREAT | O_TRUNC) &&
(affinityFile.write(affinityAdd, affinityAddLen, 0) ==
affinityAddLen)) {
char newl = '\n'; // for write()
if (affinityAdd[affinityAddLen-1] != '\n')
affinityFile.write(&newl, 1, affinityAddLen);
p.safePrintf(
"<center><b><font color=#ff0000>"
"updated affinity add file sucessfully"
"</font></b></center>");
} else {
p.safePrintf(
"<center><b><font color=#ff0000>"
"error writing affinity add file"
"</font></b></center>");
}
示例2: setCurrentTitleFileAndOffset
// . sets m_fileOffset and m_bf
// . returns false and sets g_errno on error
// . returns false if nothing to read too... but does not set g_errno
bool ImportState::setCurrentTitleFileAndOffset ( ) {
// leave m_bf and m_fileOffset alone if there is more to read
if ( m_fileOffset < m_bfFileSize )
return true;
CollectionRec *cr = g_collectiondb.getRec ( m_collnum );
if ( ! cr ) return false;
log("import: import finding next file");
// if ( m_offIsValid ) {
// //*off = m_fileOffset;
// return &m_bf;
// }
//m_offIsValid = true;
// look for titledb0001.dat etc. files in the
// workingDir/inject/ subdir
SafeBuf ddd;
ddd.safePrintf("%sinject",cr->m_importDir.getBufStart());
// now use the one provided. we should also provide the # of threads
if ( cr->m_importDir.getBufStart() &&
cr->m_importDir.getBufStart()[0] ) {
ddd.reset();
ddd.safeStrcpy ( cr->m_importDir.getBufStart() );
}
//
// assume we are the first filename
// set s_fileId to the minimum
//
Dir dir;
dir.set(ddd.getBufStart());
if ( ! dir.open() ) return false;
// assume none
long minFileId = -1;
// getNextFilename() writes into this
char pattern[64]; strcpy ( pattern , "titledb*" );
char *filename;
while ( ( filename = dir.getNextFilename ( pattern ) ) ) {
// filename must be a certain length
long filenameLen = gbstrlen(filename);
// we need at least "titledb0001.dat"
if ( filenameLen < 15 ) continue;
// ensure filename starts w/ our m_dbname
if ( strncmp ( filename , "titledb", 7 ) != 0 )
continue;
// skip if not .dat file
if ( ! strstr ( filename , ".dat" ) )
continue;
// then a 4 digit number should follow
char *s = filename + 7;
if ( ! isdigit(*(s+0)) ) continue;
if ( ! isdigit(*(s+1)) ) continue;
if ( ! isdigit(*(s+2)) ) continue;
if ( ! isdigit(*(s+3)) ) continue;
// convert digit to id
long id = atol(s);
// . do not accept files we've already processed
// . -1 means we haven't processed any yet
if ( m_bfFileId >= 0 && id <= m_bfFileId ) continue;
// the min of those we haven't yet processed/injected
if ( id < minFileId || minFileId < 0 ) minFileId = id;
}
// get where we left off
if ( ! m_loadedPlaceHolder ) {
// read where we left off from file if possible
char fname[256];
sprintf(fname,"%slasttitledbinjectinfo.dat",g_hostdb.m_dir);
SafeBuf ff;
ff.fillFromFile(fname);
if ( ff.length() > 1 ) {
m_loadedPlaceHolder = true;
// get the placeholder
sscanf ( ff.getBufStart()
, "%llu,%lu"
, &m_fileOffset
, &minFileId
);
}
}
// if no files! return false to indicate we are done
if ( minFileId == -1 ) return false;
// set up s_bf then
//if ( m_bfFileId != minFileId ) {
SafeBuf tmp;
tmp.safePrintf("titledb%04li-000.dat"
//,dir.getDirname()
,minFileId);
m_bf.set ( dir.getDirname() ,tmp.getBufStart() );
//.........这里部分代码省略.........
示例3: stopIt
//.........这里部分代码省略.........
// relative filename
char rel[200];
sprintf(rel,"/%s/parse.%llu.%li.html.diff",
testDir,h,ri);
char full[200];
sprintf(full,"/%s/parse.%llu.%li.html",
testDir,h,ri);
char validate[200];
sprintf(validate,
"/%s/parse-shortdisplay.%llu.%li.html",
testDir,h,ri);
// use red font for current run that has a diff!
char *t1 = "";
char *t2 = "";
if ( ri == m_runId && fs != 0 ) {
t1 = "<font color=pink><b>";
t2 = "</b></font>";
// a diff
udiff[un] = 1;
}
// . get critical errors
// . i.e. XmlDoc::validateOutput() could not validate
// a particular event or address that was in the
// url's "validated.uh64.txt" file since the admin
// clicked on the checkbox in the page parser output
// . if we do not find such a tag in the parser output
// any more then Spider.cpp creates this file!
if ( ri == m_runId ) {
char cfile[256];
sprintf(cfile,"%s/%s/critical.%llu.%li.txt",
g_hostdb.m_dir,testDir,h,ri);
SafeBuf ttt;
ttt.fillFromFile(cfile);
// first long is misses, then hits then events
umiss[un] = 0;
uhits[un] = 0;
uevents[un] = 0;
uunchecked[un] = 0;
if ( ttt.length() >= 3 )
sscanf(ttt.getBufStart(),
"%li %li %li %li",
&umiss[un],
&uhits[un],
&uevents[un],
&uunchecked[un]);
usort[un] = umiss[un] + uunchecked[un];
//File cf;
//cf.set(cfile);
//if ( cf.doesExist()) ucrit[un] = 1;
//else ucrit[un] = 0;
}
// more critical?
if ( ri == m_runId && umiss[un] != 0 ) {
t1 = "<font color=red><b>";
t2 = "</b></font>";
}
// . these are good to have
// . if you don't have 1+ critical hits then you
// probably need to be validate by the qa guy
char *uhb1 = "";
char *uhb2 = "";
if ( ri == m_runId && uhits[un] != 0 ) {
uhb1 = "<font color=green><b>**";