// GetFolderPath
//------------------------------------------------------------------------------
void VSProjectGenerator::GetFolderPath( const AString & fileName, AString & folder ) const
{
	const AString * const bEnd = m_BasePaths.End();
	for ( const AString * bIt = m_BasePaths.Begin(); bIt != bEnd; ++bIt )
	{
		const AString & basePath = *bIt;
		const char * begin = fileName.Get();
		const char * end = fileName.GetEnd();

		if ( fileName.BeginsWithI( basePath ) )
		{
			begin = fileName.Get() + basePath.GetLength();
			const char * lastSlash = fileName.FindLast( BACK_SLASH );
			end = ( lastSlash ) ? lastSlash : end;
			if ( begin < end )
			{
				folder.Assign( begin, end );
				return;
			}
		}
	}

	// no matching base path (use root)
	folder.Clear();
}
Exemple #2
0
// GetRemoteFilePath
//------------------------------------------------------------------------------
void ToolManifest::GetRemoteFilePath( uint32_t fileId, AString & exe, bool fullPath ) const
{
	// we'll store in the sub dir
	if ( fullPath )
	{
		GetRemotePath( exe );
	}
	else
	{
		exe.Clear();
	}

	// determine primary root
	const File & primaryFile = m_Files[ 0 ];
	AStackString<> primaryPath( primaryFile.m_Name.Get(), primaryFile.m_Name.FindLast( NATIVE_SLASH ) + 1 ); // include backslash

	const File & f = m_Files[ fileId ];
	if ( f.m_Name.BeginsWithI( primaryPath ) )
	{
		// file is in sub dir on master machine, so store with same relative location
		exe += ( f.m_Name.Get() + primaryPath.GetLength() );
	}
	else
	{
		// file is in some completely other directory, so put in same place as exe
		const char * lastSlash = f.m_Name.FindLast( NATIVE_SLASH );
		lastSlash = lastSlash ? lastSlash + 1 : f.m_Name.Get();
		exe += AStackString<>( lastSlash, f.m_Name.GetEnd() );
	}
}
//---------------------------------------------------------------------------------------------------------
//--- Test Substring
//---------------------------------------------------------------------------------------------------------
void substringConstruction( const char* inputString, AString& res, bool trim )
{
    Substring subs( inputString );
    if (trim)
        subs.Trim();
    res.Clear()._(subs);
}
// GetStatus
//------------------------------------------------------------------------------
void WorkerThreadRemote::GetStatus( AString & hostName, AString & status, bool & isIdle ) const
{
	isIdle = false;

	MutexHolder mh( m_CurrentJobMutex );
	if ( m_CurrentJob )
	{
		Server::GetHostForJob( m_CurrentJob, hostName );
		if ( IsEnabled() == false )
		{
			status = "(Finishing) ";
		}
		status += m_CurrentJob->GetRemoteName();
	}
	else
	{
		hostName.Clear();

		if ( IsEnabled() == false )
		{
			status = "(Disabled)";
		}
		else
		{
			status = "Idle";
			isIdle = true;
		}
	}
}
Exemple #5
0
// GetHostForJob
//------------------------------------------------------------------------------
/*static*/ void Server::GetHostForJob( const Job * job, AString & hostName )
{
    const ClientState * cs = (const ClientState *)job->GetUserData();
    if ( cs )
    {
        hostName = cs->m_HostName;
    }
    else
    {
        hostName.Clear();
    }
}
Exemple #6
0
// Generate
//------------------------------------------------------------------------------
/*static*/ void Args::StripQuotes( const char * start, const char * end, AString & out )
{
	ASSERT( start );
	ASSERT( end );

	// handle empty inputs
	if ( start == end )
	{
		out.Clear();
		return;
	}

	// strip first quote if there is one
	const char firstChar = *start;
	if ( ( firstChar == '"' ) || ( firstChar == '\'' ) )
	{
		++start;
	}

	// strip first quote if there is one
	const char lastChar = *( end - 1 );
	if ( ( lastChar == '"' ) || ( lastChar == '\'' ) )
	{
		--end;
	}

	// handle invalid strings (i.e. just one quote)
	if ( end < start )
	{
		out.Clear();
		return;
	}

	// assign unquoted string (could be empty, and that's ok)
	out.Assign( start, end );
}
Exemple #7
0
// GetRemoteFilePath
//------------------------------------------------------------------------------
void ToolManifest::GetRemoteFilePath( uint32_t fileId, AString & exe, bool fullPath ) const
{
	// we'll store in the sub dir
	if ( fullPath )
	{
		GetRemotePath( exe );
	}
	else
	{
		exe.Clear();
	}

	// determine primary root
	const File & primaryFile = m_Files[ 0 ];
	const File & f = m_Files[ fileId ];

	GetRelativePath( primaryFile.m_Name, f.m_Name, exe );
}
//---------------------------------------------------------------------------------------------------------
//--- Tokenizer
//---------------------------------------------------------------------------------------------------------
void tokenizerTest( const char* inputString, AString& res, char delim, char newDelim,
                    Whitespaces trim, int inpStart= -1, int inpEnd= -1  )
{
    Substring inp( inputString );
    if ( inpStart < 0 )  inpStart= 0;
    if ( inpEnd   < 0 )  inpEnd=   inp.Length() - 1;
    inp.Set( inp, inpStart, inpEnd-inpStart +1 );

    res.Clear();

    Tokenizer tok( inp, delim );

    while( tok.HasNext() )
    {
        res._( tok.Next(trim) );
        res._( newDelim );
    }

}