Exemplo n.º 1
0
void Settings::saveProfile( const std::string& savedir )
{
	std::stringstream s;
	s << time(0);
	std::string profileName( s.str() );
	
// 	std::string fulldir(savedir + "/" + profileName);
	std::string fulldir(savedir);

	if ( !dirH.exists(fulldir) )
		dirH.make(fulldir);

	std::string filename(fulldir + "/" + profileName + ".pro");
	std::stringstream buf;
	
	for( auto cvarit = cvarlist.begin(); cvarit != cvarlist.end(); ++cvarit )
	{
		if ( cvarit->second && !cvarit->second->isLocal() )
		{
			if ( cvarit->second->getType() == T_INT )
				buf << cvarit->first << " " << cvarit->second->getIntValue() << std::endl;
			else if ( cvarit->second->getType() == T_STRING )
				buf << cvarit->first << " " << cvarit->second->getStringValue() << std::endl;
		}
	}
	m_filesystem.save(filename, buf.str());

	std::string msg("Profile saved to: " + filename);
	m_logBuffer->add(msg);
	std::cerr << msg << std::endl;
}
Exemplo n.º 2
0
void Settings::saveProfile()
{
	std::stringstream s;
	s << m_profileName << "-" << time(0);
	std::string profileName( s.str() );
	
// 	std::string fulldir(savedir + "/" + profileName);
	//FIXME: savedir get from settings.xml for string "profiles". 
	//            thus fulldir is effectively "${PWD}/profiles"
	//            should fix it as to Dirlayout::progdir, which is "${HOME}/.critterding"
	//bypass the input parameter savedir
	std::string fulldir(dirlayout->profiledir);

	if ( !dirH.exists(fulldir) )
		dirH.make(fulldir);

	std::string filename(fulldir + "/" + profileName + ".pro");
	std::stringstream buf;
	
	for( auto cvarit = cvarlist.begin(); cvarit != cvarlist.end(); ++cvarit )
	{
		if ( cvarit->second && !cvarit->second->isLocal() )
		{
			if ( cvarit->second->getType() == T_INT )
				buf << cvarit->first << " " << cvarit->second->getIntValue() << std::endl;
			else if ( cvarit->second->getType() == T_STRING )
				buf << cvarit->first << " " << cvarit->second->getStringValue() << std::endl;
		}
	}
	m_filesystem.save(filename, buf.str());

	std::string msg("Profile saved to: " + filename);
	m_logBuffer->add(msg);
	std::cerr << msg << std::endl;
}
Exemplo n.º 3
0
/***************************************************************************
 * Browse subdirectories
 **************************************************************************/
int CustomBrowser::ParseDirectory(bool filteringList UNUSED)
{
	gettingList = true;
	
	ResetBrowser();

	std::string fulldir(browserRootDir);
	fulldir += browserDir;
	
	//! open the directory
	dir = opendir(fulldir.c_str());
	if(dir == NULL)
	{
		//! if we can't open the dir, try opening the root dir
		browserDir.clear();
		fulldir = browserRootDir;
		
		dir = opendir(fulldir.c_str());
		if(dir == NULL)
		{
			gettingList = false;
			return -1;
		}
	}
	
	currentpath = fulldir;
	
	ParseDirEntries();
	
	gettingList = false;
	
	return browserList.size();
}