tstring ExtractFileName(const tstring& path)
    {
        size_t pos1 = path.rfind('\\');
        size_t pos2 = path.rfind('/');

        pos1 = min(pos1, pos2);
        if (pos1 != tstring::npos)
        {
            return path.substr(pos1 + 1);
        }
        return path;
    }
void CFulEditCtrl::SetNick(const tstring& aNick) {
	if(isSet(STRIP_ISP)) {
		tstring::size_type pos = aNick.find(_T("["));
		if( pos != tstring::npos ) {
			tstring::size_type rpos = aNick.rfind(_T("]"));
			if( rpos == aNick.length() -1 && rpos > 0 ) // this user has a stupid f*****g nick bah ugly hate it
				rpos = aNick.rfind(_T("]"), rpos-1);
			if(rpos != tstring::npos) 
				nick = aNick.substr(rpos+1);
		}
	} else {
		nick = aNick;
	}
}
Example #3
0
tstring FileUtil::GetFileDirectory(const tstring &filename)
{
	tstring directory;
	const size_t last_slash_idx = filename.rfind(_T('\\'));
	if (tstring::npos != last_slash_idx)
	{
		directory = filename.substr(0, last_slash_idx);
	}

	return directory;
}
Example #4
0
/// Removes all "../" references from the absolute path fn 
/// If string contains f/d/e/../a replace it with f/d/a/
static void remove_double_dirs(tstring &fn) {
  tstring search;
  search.push_back(DIR_SEPARATOR);
  search.push_back('.');
  search.push_back('.');
  search.push_back(DIR_SEPARATOR);
  
  while (true) {
    size_t loc = fn.find(search);
    if (loc == tstring::npos) 
      break;

    // See if there is another dir separator before the /../ we just
    // found.
    size_t before = fn.rfind(DIR_SEPARATOR, loc-1);
    if (before == tstring::npos) 
      break;

    // Now delete all between before+1 and loc+3
    fn.erase(fn.begin()+before+1, fn.begin()+loc+4);
  }
}
Example #5
0
tstring get_string_suffix(const tstring& str, const tstring& separator) {
    const tstring::size_type last_separator_pos = str.rfind(separator);
    if (last_separator_pos == tstring::npos)
        return str;
    return str.substr(last_separator_pos + separator.size(), tstring::npos);
}
Example #6
0
tstring get_string_prefix(const tstring& str, const tstring& separator) {
    const tstring::size_type last_separator_pos = str.rfind(separator);
    if (last_separator_pos == string::npos)
        return str;
    return str.substr(0, last_separator_pos);
}
	/// Create array of names
	BSTR* scripts = new BSTR[files.size()];
	*names = scripts;
	*count = static_cast<ULONG>(files.size());
	for(ULONG i = 0; i < files.size(); ++i)
	{
		tstring name(files.front());
		files.pop_front();
		scripts[i] = ::SysAllocString(T2OLE(name.c_str()));
	}
CATCH_LOG_COM
}

tstring CScriptsEnumerator::GetArchiveName(const WIN32_FIND_DATA* fileData)
{
TRY_CATCH
	if(!fileData)
		return _T("");
	tstring fileName(fileData->cFileName);
	tstring::size_type pos = fileName.rfind(_T("."));
	if(tstring::npos == pos)
		return _T("");
	tstring name = fileName.substr(0, pos);
	fileName.erase(0, pos + 1);
	if(LowerCase(fileName) != tstring(SCRIPT_FILES_EXT))
		return _T("");
	return name;
CATCH_THROW()
}

/////////////////////////////////////////////////////////////////////
// 
// Function:    
//
// Description: 
//
/////////////////////////////////////////////////////////////////////
tstring CACreateProjectInitFile::ParseParameter(tstring& strSetupExeName, tstring& strParameter)
{
    tstring strParameterName;
    tstring strEncodedValue;
    tstring strParameterValue;
    tstring strError;
    size_t iParameterStart = 0;
    size_t iParameterEnd = 0;

    strParameterName = strParameter + _T("_");

    strError  = _T("Searching for parameter '");
    strError += strParameterName;
    strError += _T("'");

    LogMessage(
        INSTALLMESSAGE_INFO,
        NULL, 
        NULL,
        NULL,
        NULL,
        strError.c_str()
    );

    iParameterStart = strSetupExeName.rfind(strParameterName);
    if (iParameterStart != tstring::npos) {
        iParameterStart += strParameterName.size();
        iParameterEnd = strSetupExeName.find(_T("_"), iParameterStart);
        if (iParameterEnd == tstring::npos) {
            iParameterEnd = strSetupExeName.find(_T("."), iParameterStart);
            if (iParameterEnd == tstring::npos) {
                return tstring(_T(""));
            }
        }
        strEncodedValue = strSetupExeName.substr(iParameterStart, iParameterEnd - iParameterStart);

        strError  = _T("Found encoded value '");
        strError += strEncodedValue;
        strError += _T("'");

        LogMessage(
            INSTALLMESSAGE_INFO,
            NULL, 
            NULL,
            NULL,
            NULL,
            strError.c_str()
        );

        // WCG didn't want to have to encode their setup cookie value.  So all parameters but the setup cookie
        // are base64 encoded.
        //
        if (strParameterName == _T("asc_")) {

            strParameterValue = strEncodedValue;

        } else {

            CW2A pszASCIIEncodedValue( strEncodedValue.c_str() );
            CA2W pszUnicodeDecodedValue( r_base64_decode(pszASCIIEncodedValue, strlen(pszASCIIEncodedValue)).c_str() );

            strError  = _T("Decoded value '");
            strError += pszUnicodeDecodedValue;
            strError += _T("'");

            LogMessage(
                INSTALLMESSAGE_INFO,
                NULL, 
                NULL,
                NULL,
                NULL,
                strError.c_str()
            );

            strParameterValue = pszUnicodeDecodedValue;

        }
    }

    strError  = _T("Returning value '");
    strError += strParameterValue;
    strError += _T("'");

    LogMessage(
        INSTALLMESSAGE_INFO,
        NULL, 
        NULL,
        NULL,
        NULL,
        strError.c_str()
    );

    return strParameterValue;
}
Example #9
0
bool EditorLoader::AddLevelObject(	const tstring& modelPath,
									const tstring& physxModelPath,
									const tstring& normalPath,
									const tstring& diffusePath,
									const tstring& specPath,
									const tstring& glossPath	)
{
	if (modelPath != _T("") && physxModelPath != _T(""))
	{        
        if (physxModelPath.rfind(_T(".nxsoftbody")) == tstring::npos)
        {
            bool rigid = false;
            int ret = MessageBoxA(0, "Load as staticmesh?", "Loading: ", MB_ICONQUESTION | MB_YESNO);
		    switch (ret)
		    {
                case IDYES: rigid = false; break;
                default: rigid = true; break;
            }

            SimpleObject* pObj = new SimpleObject();

		    pObj->SetNormalPath(normalPath);

		    pObj->SetModelPath(modelPath);
		    pObj->SetPhysXModel(physxModelPath);
			
		    pObj->SetDiffusePath(diffusePath);
		    pObj->SetSpecPath(specPath);
		    pObj->SetGlossPath(glossPath);

		    pObj->SetRigid(rigid);

		    Vector3 vLook = m_pRenderContext->GetCamera()->GetLook();
		    vLook.Normalize();

		    pObj->Init(m_pPhysXEngine);

		    pObj->Translate(m_pRenderContext->GetCamera()->GetPosition() + vLook * 10);

		    m_pLevel->AddLevelObject(pObj);
        }
        else
        {
		    Vector3 vLook = m_pRenderContext->GetCamera()->GetLook();
		    vLook.Normalize();
            SimpleSoftbody* pSoftbody = new SimpleSoftbody(m_pRenderContext->GetCamera()->GetPosition() + vLook * 10);

		    pSoftbody->SetModelPath(modelPath);
		    pSoftbody->SetPhysXModel(physxModelPath);
			
		    pSoftbody->SetDiffusePath(diffusePath);
		    pSoftbody->SetSpecPath(specPath);
		    pSoftbody->SetGlossPath(glossPath);
            pSoftbody->SetNormalPath(normalPath);

            pSoftbody->Init(m_pPhysXEngine);

            m_pLevel->AddLevelObject(pSoftbody);
        }
		return true;
	}
	
	return false;
}