コード例 #1
0
 bool
 FilePlaceholderManager::holdNextPlace( bool const deleteLastPlaceholder )
 /* this looks to find the first FilenameTriple in filenameTriples which
  * has both a placeholder filename and an output filename which do not yet
  * exist in the file system, and returns true if there was such a triple.
  * if deleteLastPlaceholder is true, the previous placeholder is also
  * deleted, obviously.
  */
 {
   while( ( filenameTriples.end() > whichTriple )
          &&
          ( UsefulStuff::fileExists( whichTriple->outputFile )
            ||
            UsefulStuff::fileExists( whichTriple->placeholderFile )
            ||
            !(UsefulStuff::fileExists( whichTriple->inputFile )) ) )
   {
     ++whichTriple;
   }
   if( deleteLastPlaceholder )
   {
     UsefulStuff::runSystemCommand( "rm " + lastPlaceholder );
   }
   if( !( filenameTriples.end() > whichTriple ) )
   {
     return false;
   }
   lastPlaceholder.assign( whichTriple->placeholderFile );
   std::ofstream placeholderStream( lastPlaceholder.c_str() );
   placeholderStream << "placeholder" << std::endl;
   placeholderStream.close();
   return true;
 }
コード例 #2
0
 // This looks to find the first FilenameTriple in filenameTriples which
 // has both a placeholder filename and an output filename which do not yet
 // exist in the file system, and returns true if there was such a triple.
 // If deleteLastPlaceholder is true, the previous placeholder is also
 // deleted.
 inline bool
 FilePlaceholderManager::HoldNextPlace( bool const deleteLastPlaceholder )
 {
   bool const foundNextPlace( FindNextPlace() );
   if( deleteLastPlaceholder )
   {
     DeleteFile( lastPlaceholder );
   }
   if( foundNextPlace )
   {
     lastPlaceholder.assign( whichTriple->placeholderFile );
     std::ofstream placeholderStream( lastPlaceholder.c_str() );
     placeholderStream << "This is a placeholder!" << std::endl;
     placeholderStream.close();
     return true;
   }
   else
   {
     return false;
   }
 }