Ejemplo n.º 1
0
void RbSettings::writeUserSettings( void )
{
    std::string user_dir = RevBayesCore::RbFileManager::expandUserDir("~");
    
    // open the ini file
    std::string settings_file_name = ".RevBayes.ini";
    RevBayesCore::RbFileManager fm = RevBayesCore::RbFileManager(user_dir, settings_file_name);

    std::ofstream writeStream;
    fm.openFile( writeStream );
    writeStream << "moduledir=" << moduleDir << std::endl;
    writeStream << "printNodeIndex=" << (printNodeIndex ? "TRUE" : "FALSE") << std::endl;
    writeStream << "tolerance=" << tolerance << std::endl;
    writeStream << "linewidth=" << lineWidth << std::endl;
    writeStream << "useScaling=" << useScaling << std::endl;
    writeStream << "scalingDensity=" << scalingDensity << std::endl;
    writeStream << "collapseSampledAncestors=" << (collapseSampledAncestors ? "TRUE" : "FALSE") << std::endl;
    fm.closeFile( writeStream );

}
Ejemplo n.º 2
0
Module::Module(const std::string &fn)
{
    // first we need to load the file
    std::ifstream readStream;
    RevBayesCore::RbFileManager fm = RevBayesCore::RbFileManager(fn);
    fm.openFile( readStream );
    
    /* File-processing loop */
    while ( readStream.good() )
    {
        
        // Read a line
        std::string line;
        getline( readStream, line );
        
        commandLines.push_back( line );
        
    }

}
Ejemplo n.º 3
0
void RbSettings::initializeUserSettings(void)
{
    moduleDir = "modules";      // the default module directory
    useScaling = false;          // the default useScaling
    scalingDensity = 4;         // the default scaling density
    lineWidth = 160;            // the default line width
    tolerance = 10E-10;         // set default value for tolerance comparing doubles
    printNodeIndex = true;      // print node indices of tree nodes as comments
    collapseSampledAncestors = true;
    
    std::string user_dir = RevBayesCore::RbFileManager::expandUserDir("~");
    
    // read the ini file, override defaults if applicable
    std::string settings_file_name = ".RevBayes.ini";
    RevBayesCore::RbFileManager fm = RevBayesCore::RbFileManager(user_dir, settings_file_name);

 	
    //    bool failed = false; //unused
    if ( fm.isFile() )
    {
        std::ifstream readStream;
        fm.openFile( readStream );
        std::string readLine = "";
        while ( std::getline(readStream,readLine) )
        {
            std::vector<std::string> tokens = std::vector<std::string>();
            StringUtilities::stringSplit(readLine, "=", tokens);
            if (tokens.size() > 1)
            {
                setOption(tokens[0], tokens[1], false);
            }
        }
        
        fm.closeFile(readStream);
    }

    // initialize the current directory to be the directory the binary is sitting in
#	ifdef RB_WIN
    
    char buffer[MAX_DIR_PATH];
    GetModuleFileName( NULL, buffer, MAX_DIR_PATH );
    std::string::size_type pos = std::string( buffer ).find_last_of( "\\/" );
    workingDirectory = std::string( buffer ).substr( 0, pos);

#	else

    char cwd[MAX_DIR_PATH+1];
	if ( getcwd(cwd, MAX_DIR_PATH+1) )
    {
        std::string pathSeparator = "/";
        
        std::string curdir = cwd;
        
        if ( curdir.at( curdir.length()-1 ) == pathSeparator[0] )
        {
            curdir.erase( curdir.length()-1 );
        }
        
        workingDirectory = curdir;
	}
    else
    {
        workingDirectory = "";
    }
    
#   endif

    
    // save the current settings for the future.
//    writeUserSettings();
}