Exemple #1
0
Bool AppendString(CDynamicArray<char>& arLine, CDynamicArray<char>& arTempString, const String &str)
{
	char *pchTemp;

	Int32 lLen = str.GetCStringLen(STRINGENCODING_7BITHEX);
	if (!arLine.Append('\"')) return false;
	if (!arTempString.SetMinSizeNoCopy(3 + lLen)) return false;
	pchTemp = arTempString.GetArray();
	str.GetCString(pchTemp, lLen + 1, STRINGENCODING_7BITHEX);
	if (!AppendString(arLine, pchTemp)) return false;
	if (!arLine.Append('\"')) return false;

	return true;
}
Exemple #2
0
Bool ReadPreset(const Filename& fnPreset)
{
	AutoAlloc <BaseFile> pFile;
	if (!pFile)
		return false;

	Filename fnTemp;
	PresetElement* pPreset;
	String strName;
	Int32 n;
	CDynamicArray <char> arLine;
	char* pszLine;
	Bool bHeaderRead = false;
	String str;

	fnTemp = fnPreset.GetFile();
	fnTemp.ClearSuffix();
	strName = fnTemp.GetString();
	bHeaderRead = false;

	for (n = 0; n < g_Presets.GetElementCount(); n++)
	{
		if (g_Presets[n]->strName == strName)
			break;
	}
	if (n != g_Presets.GetElementCount())
		return false;

	pPreset = g_Presets.GetNextObject();
	if (!pPreset)
		return false;

	pPreset->strName = strName;
	if (!pFile->Open(fnPreset))
		return false;

	while (ReadLine(pFile, arLine))
	{
		pszLine = arLine.GetArray();

		if (!bHeaderRead)
		{
			if (strstr(pszLine, FILE_HEADER) == pszLine)
			{
				bHeaderRead = true;
				continue;
			}
		}
		if (!bHeaderRead)
			break;

		while (*pszLine != '\0')
		{
			if (strstr(pszLine, ORIG_PATH) == pszLine)
			{
				pszLine += strlen(ORIG_PATH);
				ReadString(pszLine, pPreset->strOrigin);
			}
			if (strstr(pszLine, DEST_PATH) == pszLine)
			{
				pszLine += strlen(DEST_PATH);
				ReadString(pszLine, pPreset->strDestination);
			}
			if (strstr(pszLine, CREATE_ZIP) == pszLine)
			{
				pszLine += strlen(CREATE_ZIP);
				ReadBool(pszLine, pPreset->bCreateZipFile);
			}
			if (strstr(pszLine, CREATE_ZIP_COMPRESSION) == pszLine)
			{
				pszLine += strlen(CREATE_ZIP_COMPRESSION);
				ReadInt32(pszLine, pPreset->lCreateZipCompressionLevel);
			}
			if (strstr(pszLine, CHECK_VERSION) == pszLine)
			{
				pszLine += strlen(CHECK_VERSION);
				ReadBool(pszLine, pPreset->bCheckVersion);
			}
			if (strstr(pszLine, PARSE_SYMBOLS) == pszLine)
			{
				pszLine += strlen(PARSE_SYMBOLS);
				ReadBool(pszLine, pPreset->bParseSymbols);
			}
			if (strstr(pszLine, WRITE_BUILD) == pszLine)
			{
				pszLine += strlen(WRITE_BUILD);
				ReadBool(pszLine, pPreset->bWriteBuildInfo);
			}
			if (strstr(pszLine, REMOVE_SCC) == pszLine)
			{
				pszLine += strlen(REMOVE_SCC);
				ReadBool(pszLine, pPreset->bRemoveSCC);
			}
			if (strstr(pszLine, BATCH) == pszLine)
			{
				pszLine += strlen(BATCH);
				ReadBool(pszLine, pPreset->bBatch);
			}
			if (strstr(pszLine, PASSWORD) == pszLine)
			{
				pszLine += strlen(PASSWORD);
				ReadString(pszLine, pPreset->strPassword);
				pPreset->strPassword = DecryptPassword(pPreset->strPassword);
			}
			if (strstr(pszLine, FILTER_STRING) == pszLine)
			{
				pszLine += strlen(FILTER_STRING);
				FilterElement* pFilter = pPreset->arFilters.GetNextObject();
				if (!pFilter)
					continue;
				ReadString(pszLine, pFilter->str);

				if (strstr(pszLine, FILTER_CONDITION) == pszLine)
				{
					pszLine += strlen(FILTER_CONDITION);
					ReadString(pszLine, str);
					if (str == W_FILTER_COND_FN_IS) pFilter->lCondition = FILTER_COND_FN_IS;
					else if (str == W_FILTER_COND_FN_EXT) pFilter->lCondition = FILTER_COND_FN_EXT;
					else if (str == W_FILTER_COND_PATH_CONTAINS) pFilter->lCondition = FILTER_COND_PATH_CONTAINS;
					else if (str == W_FILTER_COND_PATH_IS) pFilter->lCondition = FILTER_COND_PATH_IS;
					else if (str == W_FILTER_COND_DIRECTORY_IS) pFilter->lCondition = FILTER_COND_DIRECTORY_IS;
					else DebugAssert(false);
				}
				if (strstr(pszLine, FILTER_ACTION) == pszLine)
				{
					pszLine += strlen(FILTER_ACTION);
					ReadString(pszLine, str);
					if (str == W_FILTER_ACTION_INCLUDE) pFilter->lAction = FILTER_ACTION_INCLUDE;
					else if (str == W_FILTER_ACTION_EXCLUDE) pFilter->lAction = FILTER_ACTION_EXCLUDE;
					else if (str == W_FILTER_ACTION_RENAME) pFilter->lAction = FILTER_ACTION_RENAME;
					else if (str == W_FILTER_ACTION_COMPILE_INCL) pFilter->lAction = FILTER_ACTION_COMPILE_INCL;
					else if (str == W_FILTER_ACTION_MOVE_TO) pFilter->lAction = FILTER_ACTION_MOVE_TO;
					else if (str == W_FILTER_ACTION_FORCE_COPY) pFilter->lAction = FILTER_ACTION_FORCE_COPY;
					else if (str == W_FILTER_ACTION_COMPILE_INCL_KILL) pFilter->lAction = FILTER_ACTION_COMPILE_INCL_KILL;
					else DebugAssert(false);
				}
				if (strstr(pszLine, FILTER_RENAME) == pszLine)
				{
					DebugAssert(pFilter->lAction == FILTER_ACTION_RENAME);
					pszLine += strlen(FILTER_RENAME);
					ReadString(pszLine, pFilter->strRename);
				}
				else
					DebugAssert(pFilter->lAction != FILTER_ACTION_RENAME);
				if (strstr(pszLine, FILTER_FLAG) == pszLine)
				{
					pszLine += strlen(FILTER_FLAG);
					ReadString(pszLine, str);
					if (str == W_FILTER_FLAG_SET_XBIT) pFilter->bSetXBit = true;
					else DebugAssert(false);
				}
			}
			//if (pszLastPos != pszLine) always skip until the end of the line
			break;
		}
	}
	pFile->Close();
	pPreset->ulCRC = GetPresetCrc(pPreset);

	return true;
}
Exemple #3
0
void WriteLine(CDynamicArray<char>& arLine, BaseFile* pFile)
{
	pFile->WriteBytes(arLine.GetArray(), arLine.GetElementCount());
	pFile->WriteBytes((void*)"\r\n", 2);
	arLine.ResetCounter();
}