本文整理汇总了C++中TmpDir::Cd2TmpDirFile方法的典型用法代码示例。如果您正苦于以下问题:C++ TmpDir::Cd2TmpDirFile方法的具体用法?C++ TmpDir::Cd2TmpDirFile怎么用?C++ TmpDir::Cd2TmpDirFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TmpDir
的用法示例。
在下文中一共展示了TmpDir::Cd2TmpDirFile方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tokens
//-------------------------------------------------------------------------
bool
GetConfigAndAttrs( /* const */ StringList &dagFiles, bool useDagDir,
MyString &configFile, StringList &attrLines, MyString &errMsg )
{
bool result = true;
// Note: destructor will change back to original directory.
TmpDir dagDir;
dagFiles.rewind();
char *dagFile;
while ( (dagFile = dagFiles.next()) != NULL ) {
//
// Change to the DAG file's directory if necessary, and
// get the filename we need to use for it from that directory.
//
const char * newDagFile;
if ( useDagDir ) {
MyString tmpErrMsg;
if ( !dagDir.Cd2TmpDirFile( dagFile, tmpErrMsg ) ) {
AppendError( errMsg,
MyString("Unable to change to DAG directory ") +
tmpErrMsg );
return false;
}
newDagFile = condor_basename( dagFile );
} else {
newDagFile = dagFile;
}
StringList configFiles;
// Note: destructor will close file.
MultiLogFiles::FileReader reader;
errMsg = reader.Open( newDagFile );
if ( errMsg != "" ) {
return false;
}
MyString logicalLine;
while ( reader.NextLogicalLine( logicalLine ) ) {
if ( logicalLine != "" ) {
// Note: StringList constructor removes leading
// whitespace from lines.
StringList tokens( logicalLine.Value(), " \t" );
tokens.rewind();
const char *firstToken = tokens.next();
if ( !strcasecmp( firstToken, "config" ) ) {
// Get the value.
const char *newValue = tokens.next();
if ( !newValue || !strcmp( newValue, "" ) ) {
AppendError( errMsg, "Improperly-formatted "
"file: value missing after keyword "
"CONFIG" );
result = false;
} else {
// Add the value we just found to the config
// files list (if it's not already in the
// list -- we don't want duplicates).
configFiles.rewind();
char *existingValue;
bool alreadyInList = false;
while ( ( existingValue = configFiles.next() ) ) {
if ( !strcmp( existingValue, newValue ) ) {
alreadyInList = true;
}
}
if ( !alreadyInList ) {
// Note: append copies the string here.
configFiles.append( newValue );
}
}
//some DAG commands are needed for condor_submit_dag, too...
} else if ( !strcasecmp( firstToken, "SET_JOB_ATTR" ) ) {
// Strip of DAGMan-specific command name; the
// rest we pass to the submit file.
logicalLine.replaceString( "SET_JOB_ATTR", "" );
logicalLine.trim();
if ( logicalLine == "" ) {
AppendError( errMsg, "Improperly-formatted "
"file: value missing after keyword "
"SET_JOB_ATTR" );
result = false;
} else {
attrLines.append( logicalLine.Value() );
}
}
}
}
reader.Close();
//
//.........这里部分代码省略.........