Esempio n. 1
0
static void TestTCPClientKeepAlive_SendData(CTcpClient& tcpClient, const CStringBuffer& buffer)
{
	CStringBuffer sBuffer;
	CByteBuffer bBuffer;
	dword numBytesSend;

	sBuffer.FormatString(__FILE__LINE__ _T("##%05d## %s"), buffer.GetLength(), buffer.GetString());
	sBuffer.convertToByteBuffer(bBuffer);
	tcpClient.SendData(bBuffer.get_Buffer(), bBuffer.get_BufferSize(), &numBytesSend);
	assert(numBytesSend == bBuffer.get_BufferSize());
}
Esempio n. 2
0
	void SendData(CTcpClient* tcpClient, const CStringBuffer& buffer)
	{
		CScopedLock _lock;
		CStringBuffer sBuffer;
		CByteBuffer bBuffer;
		dword numBytesSend;

		sBuffer.FormatString(__FILE__LINE__ _T("##%05d## %s"), buffer.GetLength(), buffer.GetString());
		sBuffer.convertToByteBuffer(bBuffer);
		_lock.unlock();
		tcpClient->SendData(bBuffer.get_Buffer(), bBuffer.get_BufferSize(), &numBytesSend);
		assert(numBytesSend == bBuffer.get_BufferSize());
	}
Esempio n. 3
0
	virtual int main()
	{
		CStreamFile* pOutFile = NULL;
		CFilePath fcurdir;
		CFilePath fziparchive(__FILE__LINE__ m_sZipArchive);
		CFilePath foutf(__FILE__LINE__ m_sOutputFile);
		int result = 0;

		if ( m_help )
		{
			CStringBuffer tmp;

			usage(tmp);
			CERR << tmp;
			return 0;
		}
		if ( !m_AnyZipOption )
		{
			m_AnyZipOption = true;
			m_bAddFiles = true;
		}
		if (m_bInputDir)
		{
			CFilePath finputdir(__FILE__LINE__ m_sInputDir);

			if (CWinDirectoryIterator::FileExists(finputdir))
				finputdir.set_Filename(NULL);
			finputdir.MakeDirectory();
			if (CWinDirectoryIterator::DirectoryExists(finputdir) < 0)
			{
				CERR << finputdir.get_Path() << _T(" does not exist.") << endl;
				return -4;
			}
			CDirectoryIterator::GetCurrentDirectory(fcurdir);
			fziparchive.MakeAbsolute();
			if (m_bOutputFile)
				foutf.MakeAbsolute();
			CDirectoryIterator::SetCurrentDirectory(finputdir);
		}
		if (m_bOutputFile) 
		{
			if (CDirectoryIterator::FileExists(foutf))
				CDirectoryIterator::RemoveFile(foutf);
			else if (foutf.is_File())
			{
				CFilePath tmp(foutf);

				tmp.set_Filename(NULL);
				CDirectoryIterator::MakeDirectory(tmp);
			}
			else
			{
				CDateTime now;
				CStringBuffer tmp;

				now.Now();
				tmp.FormatString(__FILE__LINE__ _T("XZip%04hd%02hd%02hd%02hd%02hd%02hd.log"),
					now.GetYears(), now.GetMonths(), now.GetDays(),
					now.GetHours(), now.GetMinutes(), now.GetSeconds());
				foutf.set_Filename(tmp);
			}
			pOutFile = OK_NEW_OPERATOR CStreamFile;
			pOutFile->ReOpen(foutf, stdout);
		}
		if ( m_bAddFiles )
		{
			if (!m_bZipFileSpec)
			{
				CERR << _T("No FileSpec given. Do not know, what to do.") << endl;
				result = -4;
			}
			else
				XZipAddFiles(fziparchive, m_bRecurseFolders, m_sZipFileSpec, m_sExclude);
		}
		if ( m_bViewFiles )
		{
			if ( !m_bZipFileSpec )
				m_sZipFileSpec.Append(_T("*.*"));
			XZipViewFiles(fziparchive, m_sZipFileSpec, m_sExclude, m_sViewFiles);
		}
		if ( m_bFreshenFiles )
		{
			if ( !m_bZipFileSpec )
				m_sZipFileSpec.Append(_T("*.*"));
			XZipFreshenFiles(fziparchive, m_sZipFileSpec, m_sExclude);
		}
		if ( m_bUpdateFiles )
		{
			if ( !m_bZipFileSpec )
			{
				CERR << _T("No FileSpec given. Do not know, what to do.") << endl;
				result = -4;
			}
			else
				XZipUpdateFiles(fziparchive, m_bRecurseFolders, m_sZipFileSpec, m_sExclude);
		}
		if (pOutFile)
		{
			pOutFile->Close();
			pOutFile->release();
		}
		if (m_bInputDir)
			CDirectoryIterator::SetCurrentDirectory(fcurdir);
		return result;
	}