Ejemplo n.º 1
0
// -----------------------------------------------------------------------------
// CATBase::DirDelete
// Delelete directory
// -----------------------------------------------------------------------------
bool CATBase::DirDelete(const string& sDir, bool bPrint )
{
	LOG_FUNC_ENTRY("CATBase::DirDelete");
	if ( sDir.find( AT_TEMP_DIR) == string::npos )
		return false;
	
	if ( sDir.length() < 2 )
		return false;

	string sDir2;
	if ( sDir.at(1) != ':' )
	{
		char cDir[MAX_LINE_LENGTH];
		GetCurrentDirectory( MAX_LINE_LENGTH , cDir );
		sDir2.append( cDir );
		sDir2.append( "\\" );
		sDir2.append( sDir );
	}
	else
		sDir2.append( sDir );

	// does directory exists
	DWORD dwRet = GetFileAttributes( sDir2.c_str() );
	if ( dwRet == INVALID_FILE_ATTRIBUTES )
		return false;
	else if ( ! (dwRet & FILE_ATTRIBUTE_DIRECTORY) )
	{
		return false;
	}
	// Delete dir
	string sCmd( "rmdir /S /Q " );
	sCmd.append( sDir2 );
	sCmd.append( " > nul 2>&1" );
	int iRet = (int)system( sCmd.c_str() );
	if ( iRet && bPrint)
	{
		cout << AT_MSG << "Error, deleting directory " << sDir2 << endl;
	}
	else if ( !iRet && bPrint )
	{
		cout << AT_MSG << "Delete directory " << sDir2 << endl;
	}
	if ( iRet )
		return false;
	return true;
}
Ejemplo n.º 2
0
void ToSaMeshThreadSocket::TickFromUi() {
	if (fdClient == -1)
		return;
	fd_set fds;
	FD_ZERO(&fds);
	FD_SET(fdClient, &fds);
	struct timeval timeout;
	timeout.tv_sec = 0;
	timeout.tv_usec = 1;
	select(sizeof(fds)*8, &fds, NULL, NULL, &timeout);
	if (FD_ISSET(fdClient, &fds)) {
		char sBuf[TOSA_MESH_SOCKET_BUF];
		memset(sBuf, '\0', TOSA_MESH_SOCKET_BUF);
		int msglen = recv(fdClient, sBuf, TOSA_MESH_SOCKET_BUF, 0);
		std::string sCmd(sBuf);
		LOG4CXX_INFO(logger, "ToSaMeshThreadSocket: command received: " << sCmd);
		disp->mqFromUi->enqueue(*this, new ToSaMeshThreadMessageJson(sCmd));
	}
}