Example #1
0
RCommitLog::RCommitLog(std::string logfile, int firstChar) {

    logf     = 0;
    seekable = false;
    success  = false;
    is_dir   = false;
    buffered = false;

    if(logfile == "-") {

        //check first char
        if(checkFirstChar(firstChar, std::cin)) {
            logf     = new StreamLog();
            is_dir   = false;
            seekable = false;
            success  = true;
        }

        return;
    }

    struct stat fileinfo;
    int rc = stat(logfile.c_str(), &fileinfo);

    if(rc==0) {
        is_dir = (fileinfo.st_mode & S_IFDIR) ? true : false;

        if(!is_dir) {

            //check first char
            std::ifstream testf(logfile.c_str());

            bool firstOK = checkFirstChar(firstChar, testf);

            testf.close();

            if(firstOK) {
                logf = new SeekLog(logfile);
                seekable = true;
                success = true;
            }
        }
    }
}
Example #2
0
static bool checkGobaku(const std::wstring& titleW,const std::wstring& searchW,const std::wstring& innerW,const std::wstring& word)
{
	//検索に使ったワードとご判定をけるため消す.
	std::wstring sss = XLWStringUtil::replace(innerW,searchW,L"   ");

	int pos = sss.find(word);
	if (pos == std::wstring::npos )
	{
		return true;
	}

	//ヒットした場所から、前に英数とかっこがあれば戻します.
	for( ; pos > 0 ; pos --)
	{
		if ( XLWStringUtil::isAlphanum( sss[pos] ) )
		{
			continue;
		}
		else if ( XLWStringUtil::isSpace( sss[pos] ) )
		{
			continue;
		}
		else if ( sss[pos] == L'\n' )
		{
			break;
		}
		else if ( sss[pos] == L'|' || sss[pos] == L'-' || sss[pos] == L':' || sss[pos] == L'{' || sss[pos] == L'(' || sss[pos] == L'('|| sss[pos] == L'「' )
		{
			continue;
		}
		else 
		{
			break;
		}
	}

	//ヒットしたワードの場所から、後ろにN文字以内に漢字が
	//「狩猟」({{lang-en-short|hunting}})
	int endpos = MAX( pos - 10 , 0);
	for(int i = pos ; i > endpos ; i-- )
	{
		if ( XLWStringUtil::isKanji( sss[i] ) )
		{
			return true;
		}
		else if (sss[pos] == L'\n')
		{
			break;
		}
		else if (sss[pos] == L'。')
		{
			break;
		}
	}

	if (! checkFirstChar(titleW,word) )
	{//最初の一文字比較.
		return true;
	}

	return false;
}