Пример #1
0
    Win32NamedPipeServerTransport::Win32NamedPipeServerTransport(
        const tstring & pipeName) :
            IocpServerTransport(),
            mpSec(RCF_DEFAULT_INIT),
            mQueuedAccepts(RCF_DEFAULT_INIT),
            mPipeNameLock(INVALID_HANDLE_VALUE)
    {
        if (pipeName.empty())
        {
            // Generate a pipe name dynamically, that won't conflict with any
            // other test executables that may be running concurrently.

            std::pair<tstring, HANDLE> pipeAndHandle = generateNewPipeName();
            mPipeName = pipeAndHandle.first + RCF_T("_0");
            mPipeNameLock = pipeAndHandle.second;
        }
        else
        {
            if (pipeName.at(0) == RCF_T('\\'))
            {
                mPipeName = pipeName;
            }
            else
            {
                mPipeName = RCF_T("\\\\.\\pipe\\") + pipeName;
            }
        }
    }
Пример #2
0
void litehtml::el_before_after_base::add_text( const tstring& txt )
{
	tstring word;
	tstring esc;
	for(tstring::size_type i = 0; i < txt.length(); i++)
	{
		if( (txt.at(i) == _t(' ')) || (txt.at(i) == _t('\t')) || (txt.at(i) == _t('\\') && !esc.empty()) )
		{
			if(esc.empty())
			{
				if(!word.empty())
				{
					element::ptr el = std::make_shared<el_text>(word.c_str(), get_document());
					appendChild(el);
					word.clear();
				}

				element::ptr el = std::make_shared<el_space>(txt.substr(i, 1).c_str(), get_document());
				appendChild(el);
			} else
			{
				word += convert_escape(esc.c_str() + 1);
				esc.clear();
				if(txt.at(i) == _t('\\'))
				{
					esc += txt.at(i);
				}
			}
		} else
		{
			if(!esc.empty() || txt.at(i) == _t('\\'))
			{
				esc += txt.at(i);
			} else
			{
				word += txt.at(i);
			}
		}
	}

	if(!esc.empty())
	{
		word += convert_escape(esc.c_str() + 1);
	}
	if(!word.empty())
	{
		element::ptr el = std::make_shared<el_text>(word.c_str(), get_document());
		appendChild(el);
		word.clear();
	}
}
Пример #3
0
void GetFiles(const tstring& path, vector<tstring>& files, const tstring& mask /* = string() */)
{
	tstring root = path;
	const TCHAR ch = path.at(path.length() - 1);
	if (TEXT('\\') != ch)
	{
		root += TEXT('\\');
	}
	tstring pattern;
	if (mask.empty())
	{
		pattern = root + TEXT('*');
	}
	else
	{
		pattern = root + mask;
	}

	WIN32_FIND_DATA data;
	ZeroMemory(&data, sizeof(data));
	HANDLE handle = FindFirstFile(pattern.c_str(), &data);
	if (INVALID_HANDLE_VALUE == handle)
	{
		return;
	}
	try
	{
		for (BOOL status = TRUE; status; status = FindNextFile(handle, &data))
		{
			tstring st = data.cFileName;
			if ((TEXT(".") == st) || (TEXT("..") == st))
			{
				continue;
			}
			if (!(data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
			{
				files.push_back(root + st);
			}
		}
		FindClose(handle);
	}
	catch (const bad_alloc&)
	{
		FindClose(handle);
		throw;
	}
}
Пример #4
0
void CFTPProtocolOutput::OnResponse(const tstring& strResponse)
{
   if( strResponse.length()==0 )
      return;

   COLORREF crText = RGB(0, 150, 0);
   switch( strResponse.at(0) )
   {
   case _T('4'):
      crText = RGB(200, 200, 0);
      break;
   case _T('5'):
      crText = RGB(255, 0, 0);
      break;
   }

   WriteLine(_T("< ") + CString(strResponse.c_str()) + _T("\n"), crText);
}