void SplitSysListContent(const CStringA& strContent)
{
	USES_CONVERSION;

	int curPos = 0;
	CStringA resToken = strContent.Tokenize("\r\n", curPos);
	while (resToken != "")
	{
		resToken.Trim();

		if (!resToken.IsEmpty() && resToken.GetAt(0) != '#')
		{
			int nPoundKey = resToken.Find('#');
			if (nPoundKey != -1)
				resToken = resToken.Mid(0, nPoundKey);

			resToken.Replace('/', '\\');

			// (1) 注册表
			if (resToken.GetAt(0) == '$')
			{
				if (resToken.GetLength() > 3)
				{
					if (resToken.GetAt(1) == '{')
						DoRegistryPath(resToken);
					else if (resToken.GetAt(1) == '[')
						DoRegistryFile(resToken);
				}
			}
			// (2) 单独文件
			else if (resToken.GetAt(0) == '@')
				DoOnlyFileName(resToken.Mid(1));

			// (3) 其他
			else
				DoFilePathName(resToken);
		}

		resToken = strContent.Tokenize("\r\n", curPos);
	}
}
Esempio n. 2
0
CStringA	FxInternal::TranscodeHandleToPlug (const CStringA& handleStr)
{
	int iLastPos=0;
	int iThisPos=0;

	CStringA result(DirectXShader::RootLongName.asChar());
	CStringA partial(DirectXShader::RootShortName.asChar());

	CStringA subStr;
	while( iLastPos= iThisPos, 
		subStr=handleStr.Tokenize(".[]", iThisPos), 
		iThisPos != -1 )
	{
		if(iLastPos == 0 
			|| handleStr[iLastPos-1]=='.'
			|| (handleStr[iLastPos-1]==']' && handleStr[iLastPos]=='.'))
		{
			partial.Append(subStr.GetString());
			result.AppendFormat(".%s", partial.GetString());
		}
		else if(handleStr[iLastPos-1]=='[' && handleStr[iThisPos-1]==']')
		{
			result.AppendFormat("[%s]", subStr);
		}
		else
			DXCC_ASSERT(false);
	}


	D3DXPARAMETER_DESC		desc;
	D3DXHANDLE handle= DecodeHandle(handleStr);
	Effect->GetParameterDesc(handle, &desc);
	if( desc.StructMembers == 0 && desc.Elements == 0 )
	{
		partial.Append("Value");
		result.AppendFormat(".%s", partial);
	}

	return result;
}
Esempio n. 3
0
//THIS FUNCTION IS QUITE COMPLICATED BECAUSE 
//IT HAS TO DEAL WITH MAYA NAME MANGLING!
//tokenize the path.
//add each token into the element list which tracks the attributes and indices
//for each entry added make sure there are no parents left out from maya name mangling.
//after the list is populated and missing elements area added 
//we reiterate and produce the final result.
MPlug		FxInternal::DecodePlug(const CStringA& plugStr)
{

	MPlug result;
	MFnDependencyNode depNode(GetSite());

	CAtlList<PathDecodeElement> elementList;

	//tokenize the path
	int iLastPos=0;
	int iThisPos=0;
	CStringA subStr;
	while( iLastPos= iThisPos, 
		subStr=plugStr.Tokenize(".[]", iThisPos), 
		iThisPos != -1 )
	{
		//char lastChar= subStr[iLastPos];
		//char thisChar= subStr[iThisPos];

		//are we looking at a named portion?
		if(iLastPos == 0 
			|| plugStr[iLastPos-1]=='.'
			|| (plugStr[iLastPos-1]==']' && plugStr[iLastPos]=='.'))
		{
			//if the name is length zero then it must be the case when 
			// you do last[#].  The situation is caused by  the sequence "]."
			//if we dont have a name we can skip since only 1d arrays are allowed.

			if(subStr.GetLength() > 0)
			{
		
				//everything we add is going to be based on the current tail.
				//because we are adding parents, as we find parents we can continue
				//to add them to this position so that they will order themselves properly
				POSITION insertPos= elementList.GetTailPosition();

				//calculate the cancel condition.
				//it is the current tail's object if a tail exists otherwise NULL
				//NULL indicates go all the way to the root
				MObject cancelObj= MObject::kNullObj;
				if(elementList.GetCount() > 0)
				{
					cancelObj= elementList.GetTail().Attribute.object();
				}


				//get the object we are currently working with
				MObject thisObj= depNode.attribute(subStr.GetString());
				if(thisObj.isNull())
					return MPlug();//Critical element of the path was not found...return NULL


				//add it to the list so that we have something to insertBefore
				elementList.AddTail();
				elementList.GetTail().Name= subStr;
				elementList.GetTail().Attribute.setObject(thisObj);



				//walk through all of the parents until we reach cancel condition.
				//we can add  the current element onto the list in the same way.
				for( MFnAttribute itrAttr( elementList.GetTail().Attribute.parent() );
					!itrAttr.object().isNull()  && (cancelObj != itrAttr.object());
					itrAttr.setObject(itrAttr.parent()))
				{
					PathDecodeElement element;
					element.Attribute.setObject( itrAttr.object() );

					//we change the position so that the grandparent is inserted before the parent
					insertPos= elementList.InsertBefore( insertPos, element);
				}
			}
		}
		//are we looking at a numbered portion?
		else if(plugStr[iLastPos-1]=='[' && plugStr[iThisPos-1]==']')
		{
			//if so change the array index.
			elementList.GetTail().IsArray= true;
			elementList.GetTail().Index = atoi( subStr.GetString() );
		}
		else
			DXCC_ASSERT(false);//VERY POORLY FORMED STRING

	}

	//produce the result plug off of the elementList.
	bool first= true;
	for(POSITION pos= elementList.GetHeadPosition();
		pos != NULL;
		elementList.GetNext(pos))
	{
		PathDecodeElement& element= elementList.GetAt(pos);

		if(first)
		{//on first one we initialize the result 
			first= false;
			result= MPlug( GetSite(), element.Attribute.object() );
		}
		else
		{
			result= result.child( element.Attribute.object() );
		}

		if(element.IsArray)
		{
			result= result.elementByLogicalIndex(element.Index);
		}


		if(result.isNull())
			return MPlug();//Critical element of the path was not found...return NULL
	}


	return result;
}
Esempio n. 4
0
bool IgnoreCommand::Execute()
{
	bool bmask=false;

	if(parser.HasKey(_T("onlymask")))
	{
		bmask=true;
	}

	bool ret = CAppUtils::IgnoreFile(pathList,bmask);

	if (parser.HasKey(_T("delete")))
	{
		int key;

		CString format;

		if(CMessageBox::Show(hwndExplorer, _T("Keep file locally?"), _T("TortoiseGit"), MB_ICONERROR|MB_YESNO) == IDYES)
		{
			format= _T("git.exe update-index --force-remove -- \"%s\"");
		}
		else
		{
			format=_T("git.exe rm -r -f -- \"%s\"");
		}

		CString output;
		CString cmd;
		int nPath;
		for(nPath = 0; nPath < pathList.GetCount(); nPath++)
		{

			cmd.Format(format,pathList[nPath].GetGitPathString());
			if(g_Git.Run(cmd,&output,CP_ACP))
			{
				key=CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONERROR|MB_OKCANCEL);
				if(key == IDCANCEL)
					return FALSE;

			}
		}

		output.Format(_T("%d files removed"),nPath);

		CShellUpdater::Instance().AddPathsForUpdate(pathList);

		CMessageBox::Show(hwndExplorer, output, _T("TortoiseGit"), MB_ICONINFORMATION|MB_OK);
	}

	CShellUpdater::Instance().AddPathsForUpdate(orgPathList);
	CShellUpdater::Instance().Flush();

	return ret;
#if 0
	CString filelist;
	BOOL err = FALSE;
	for(int nPath = 0; nPath < pathList.GetCount(); nPath++)
	{
		CString name = CPathUtils::PathPatternEscape(pathList[nPath].GetFileOrDirectoryName());
		if (parser.HasKey(_T("onlymask")))
		{
			name = _T("*")+pathList[nPath].GetFileExtension();
		}
		filelist += name + _T("\n");
		CTSVNPath parentfolder = pathList[nPath].GetContainingDirectory();
		SVNProperties props(parentfolder, SVNRev::REV_WC, false);
		CStringA value;
		for (int i=0; i<props.GetCount(); i++)
		{
			CString propname(props.GetItemName(i).c_str());
			if (propname.CompareNoCase(_T("svn:ignore"))==0)
			{
				//treat values as normal text even if they're not
				value = (char *)props.GetItemValue(i).c_str();
			}
		}
		if (value.IsEmpty())
			value = name;
		else
		{
			// make sure we don't have duplicate entries
			std::set<CStringA> ignoreItems;
			ignoreItems.insert(CUnicodeUtils::GetUTF8(name));
			CStringA token;
			int curPos = 0;
			token= value.Tokenize("\n",curPos);
			while (token != _T(""))
			{
				token.Trim();
				ignoreItems.insert(token);
				token = value.Tokenize("\n", curPos);
			};
			value.Empty();
			for (std::set<CStringA>::iterator it = ignoreItems.begin(); it != ignoreItems.end(); ++it)
			{
				value += *it;
				value += "\n";
			}
		}
		if (!props.Add(_T("svn:ignore"), (LPCSTR)value))
		{
			CString temp;
			temp.Format(IDS_ERR_FAILEDIGNOREPROPERTY, (LPCTSTR)name);
			temp += _T("\n");
			temp += props.GetLastErrorMsg().c_str();
			CMessageBox::Show(hwndExplorer, temp, _T("TortoiseGit"), MB_ICONERROR);
			err = TRUE;
			break;
		}
	}
	if (err == FALSE)
	{
		CString temp;
		temp.Format(IDS_PROC_IGNORESUCCESS, (LPCTSTR)filelist);
		CMessageBox::Show(hwndExplorer, temp, _T("TortoiseGit"), MB_ICONINFORMATION);
		return true;
	}
#endif
}