コード例 #1
0
ファイル: optionspage.cpp プロジェクト: steveatinfincia/fms
const std::string OptionsPage::GenerateContent(const std::string &method, const std::map<std::string,QueryVar> &queryvars)
{
	std::string content("");
	std::string sql("");

	if(queryvars.find("formaction")!=queryvars.end() && (*queryvars.find("formaction")).second=="save" && ValidateFormPassword(queryvars))
	{
		Option option(m_db);
		option.ClearCache();
		std::vector<std::string> options;
		std::vector<std::string> oldvalues;
		std::vector<std::string> newvalues;
		CreateArgArray(queryvars,"option",options);
		CreateArgArray(queryvars,"oldvalue",oldvalues);
		CreateArgArray(queryvars,"value",newvalues);

		for(int i=0; i<options.size(); i++)
		{
			if(oldvalues[i]!=newvalues[i])
			{

				option.Set(options[i],newvalues[i]);

				// load new language immediately
				if(options[i]=="Language")
				{
					Poco::Path tdir;
					tdir.pushDirectory(global::basepath+"translations");
					tdir=tdir.makeAbsolute();
					tdir.setFileName(newvalues[i]);
					m_trans->LoadLocalizedTranslation(tdir.toString());
				}

				if(options[i]=="MessageDownloadMaxDaysBackward")
				{
					m_db->Execute("INSERT OR IGNORE\
								INTO tblMessageRequests (IdentityID, Day, RequestIndex, Found)\
								SELECT M.IdentityID, M.InsertDate, M.MessageIndex, 'true'\
								FROM tblMessage M\
								LEFT JOIN tblMessageRequests R\
									ON M.IdentityID=R.IdentityID\
									AND M.MessageIndex=R.RequestIndex\
									AND M.InsertDate=R.Day\
								WHERE R.IdentityID IS NULL\
								AND M.IdentityID IS NOT NULL\
								AND M.InsertDate >= date('now',(SELECT -MAX(OptionValue,0) FROM tblOption \
									WHERE Option='MessageDownloadMaxDaysBackward')||' days');");
				}
			}
コード例 #2
0
ファイル: Utils.cpp プロジェクト: damiannz/openFrameworks
string getOFRelPath(string from){
    Poco::Path base(true);
    base.parse(from);

    Poco::Path path;
    path.parse( getOFRoot() );
    path.makeAbsolute();

    
    cout << "getOFRelPath " << base.toString() << " " << path.toString() << endl;
    
	string relPath;
	if (path.toString() == base.toString()){
		// do something.
	}

	int maxx = MAX(base.depth(), path.depth());
	for (int i = 0; i <= maxx; i++){

		bool bRunOut = false;
		bool bChanged = false;
		if (i <= base.depth() && i <= path.depth()){
			if (base.directory(i) == path.directory(i)){

			} else {
				bChanged = true;
			}
		} else {
			bRunOut = true;
		}
		if (bRunOut == true || bChanged == true){
			for (int j = i; j <= base.depth(); j++){
				relPath += "../";
			}
			for (int j = i; j <= path.depth(); j++){
				relPath += path.directory(j) + "/";
			}
			break;
		}
	}
    
    cout << relPath << " ---- " << endl;
    
    
    return relPath;
}
コード例 #3
0
Poco::Path SharedMemoryTest::findDataFile(const std::string& afile)
{
	Poco::Path root;
	root.makeAbsolute();
	Poco::Path result;
	while (!Poco::Path::find(root.toString(), "data", result))
	{
		root.makeParent();
		if (root.toString().empty() || root.toString() == "/")
			throw Poco::FileNotFoundException("Didn't find data subdir");
	}
	result.makeDirectory();
	result.setFileName(afile);
	Poco::File aFile(result.toString());
	if (!aFile.exists() || (aFile.exists() && !aFile.isFile()))
		throw Poco::FileNotFoundException("Didn't find file " + afile);
	
	return result;
}