Error SourceManager::source(const FilePath& filePath, bool local)
{
   std::string localPrefix = local ? "local(" : "";
   std::string localParam = local ? "TRUE" : "FALSE" ;
   std::string localSuffix = local ? ")" : "";
      
   // do \ escaping (for windows)
   std::string path = filePath.absolutePath();
   boost::algorithm::replace_all(path, "\\", "\\\\");

   // Build the code. If this build is targeted for debugging, keep the source
   // code around; otherwise, turn it off to conserve memory and expose fewer
   // internals to the user.
   std::string rCode = localPrefix + "source(\"" 
                           + path + "\", " +
                           "local=" + localParam + ", " + 
                           "echo=FALSE, " +
                           "verbose=FALSE, " + 
#ifdef NDEBUG
                           "keep.source=FALSE, " +
#else
                           "keep.source=TRUE, " +
#endif
                           "encoding='UTF-8')" + localSuffix;
      
   // record that we sourced the file. 
   recordSourcedFile(filePath, local);

   // source the file
   return r::exec::executeString(rCode); 
}
Beispiel #2
0
Error SourceManager::source(const FilePath& filePath, bool local)
{
   std::string localPrefix = local ? "local(" : "";
   std::string localParam = local ? "TRUE" : "FALSE" ;
   std::string localSuffix = local ? ")" : "";
      
   // do \ escaping (for windows)
   std::string path = filePath.absolutePath();
   boost::algorithm::replace_all(path, "\\", "\\\\");

   // build the code 
   std::string rCode = localPrefix + "source(\"" 
                           + path + "\", " +
                           "local=" + localParam + ", " + 
                           "echo=FALSE, " +
                           "verbose=FALSE, " + 
                           "encoding='UTF-8')" + localSuffix;
      
   // record that we sourced the file. 
   recordSourcedFile(filePath, local);
   
   // source the file
   return r::exec::executeString(rCode); 
}