⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseconfig.cc

📁 About: Paco (pacKAGE oRGANIZER) is a simple, yet powerful tool to aid package management when insta
💻 CC
字号:
//=======================================================================// BaseConfig.cc//-----------------------------------------------------------------------// This file is part of the package paco// Copyright (C) 2004-2007 David Rosal <david.3r@gmail.com>// For more information visit http://paco.sourceforge.net//=======================================================================#include "config.h"#include "paco.h"#include "BaseConfig.h"#include <fstream>using std::string;using namespace Paco;// Forward declarationsstatic string expandHome(string const& str);namespace Paco{	string BaseConfig::sLogdir			= LOGDIR;	string BaseConfig::sInclude			= INCLUDE;	string BaseConfig::sExclude			= EXCLUDE;	bool BaseConfig::sLogIgnoreErrors	= false;	bool BaseConfig::sLogIgnoreShared	= false;	bool BaseConfig::sCaseSensitive		= false;	int BaseConfig::sBlockSize			= DEFAULT_BLOCK_SIZE;	int BaseConfig::sMaxDbAge			= DEFAULT_MAX_DB_AGE;}BaseConfig::BaseConfig(string const& __logdir){	if (!__logdir.empty())		sLogdir = __logdir;	std::ifstream f(PACORC);	if (!f)		return;	string buf;	while (getline(f, buf)) {		string::size_type p(buf.find("="));		if (p == string::npos || buf[0] == '#')   			continue;		string val(buf.substr(p + 1));		buf.erase(p);   		if (val == "1") {			if (buf == "LOG_IGNORE_ERRORS")   				sLogIgnoreErrors = true;			if (buf == "LOG_IGNORE_SHARED")   				sLogIgnoreShared = true;			if (buf == "APPARENT_SIZE")   				sBlockSize = 1;			else if (buf == "CASE_SENSITIVE")   				sCaseSensitive = true;		}		else if (buf == "BLOCK_SIZE")   			sBlockSize = str2num<int>(val);		else if (buf == "MAX_DB_AGE")   			sMaxDbAge = str2num<int>(val);		else if (buf == "LOGDIR")   			sLogdir = expandHome(val);		else if (buf == "INCLUDE")   			sInclude = expandHome(val);		else if (buf == "EXCLUDE")   			sExclude = expandHome(val);	}}BaseConfig::~BaseConfig(){ }// [static]void BaseConfig::init(string const& __logdir){	static BaseConfig c(__logdir);}// [static]void BaseConfig::touchStamp(){	std::ofstream f(stamp().c_str());	if (f)		f << PACKAGE_VERSION "\n";}// [static]string BaseConfig::version(){	string v;	std::ifstream f(stamp().c_str());	if (f)		f >> v;	return v;}//// Expand environment variable HOME in str//static string expandHome(string const& str){	string ret(str);	if (char* home = getenv("HOME")) {		string::size_type p;		for (p = 0; (p = ret.find("$HOME", p)) != string::npos; )			ret.replace(p, 5, home);		for (p = 0; (p = ret.find("${HOME}", p)) != string::npos; )			ret.replace(p, 7, home);    }	return ret;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -