Example #1
0
void CNamedIndexes::TestGetPotentialContainingBlocks(char* szName, CArrayNamedIndexesBlockPtr* pcDest)
{
	int						i;
	CNamedIndexesBlocks*	pcBlock;
	int						iNameLength;
	CChars	szFake;

	if (!szName)
	{
		return;
	}

	szFake.Fake(szName);
	if (szFake.Empty())
	{
		return;
	}
	
	iNameLength = (int)strlen(szName);
	for (i = 0; i < macBlocks.NumElements(); i++)
	{
		pcBlock = macBlocks.Get(i);
		if (pcBlock->FitsLength(iNameLength))
		{
			pcBlock->GetPotentialContainingBlocks(&szFake, pcDest);
		}
	}
}
//////////////////////////////////////////////////////////////////////////
//																		//
//																		//
//////////////////////////////////////////////////////////////////////////
int CArrayString::FindInSorted(char* szString, BOOL bCaseSensitive)
{
	CChars	szFake;

	szFake.Fake(szString);
	return FindInSorted(&szFake, bCaseSensitive);
}
Example #3
0
BOOL CNamedIndexes::Remove(char* szName)
{
	CChars	szFake;

	szFake.Fake(szName);
	return Remove(&szFake);
}
//////////////////////////////////////////////////////////////////////////
//																		//
//																		//
//////////////////////////////////////////////////////////////////////////
CChars* CArrayString::InsertIntoSorted(char* szText, char* szLastCharInclusive)
{
	CChars*		pcChars2;
	CChars		szTemp;
	char		c;
	BOOL		bResult;
	int			iIndex;

	c = szLastCharInclusive[1];
	szLastCharInclusive[1] = 0;
	szTemp.Fake(szText);

	bResult = mcArray.FindInSorted(&szTemp, CompareChars, &iIndex);
	if (bResult)
	{
		szLastCharInclusive[1] = c;
		return mcArray.Get(iIndex);
	}
	else
	{
		szLastCharInclusive[1] = c;
		pcChars2 = mcArray.InsertAt(iIndex);
		pcChars2->Init(szText, 0, (int)(szLastCharInclusive-szText)+1);
		return pcChars2;	
	}
}
CPackFile* CFiles::GetPackFile(char* szFullName)
{
	CPackFileOffset*	pcPackFiles;
	int					i;
	CChars				sz;
	BOOL				bResult;
	CPackFile*			pcPackFile;

	sz.Fake(szFullName);
	for (i = 0; i < mcPackFilesArray.NumElements(); i++)
	{
		pcPackFiles = mcPackFilesArray.Get(i);
		bResult = sz.StartsWith(pcPackFiles->mszOffset.Text());
		if (bResult)
		{
			pcPackFile = GetPackFile(pcPackFiles, szFullName);
			if (pcPackFile)
			{
				return pcPackFile;
			}
		}
	}
	
	return NULL;
}
Example #6
0
BOOL CNamedIndexes::Add(OIndex oi, char* szName, BOOL bFailOnExisting)
{
	CChars	szFake;
	BOOL	bResult;

	szFake.Fake(szName);
	bResult = Add(oi, &szFake, bFailOnExisting);
	return bResult;
}
Example #7
0
OIndex CNamedIndexes::GetIndex(char* szName)
{
	CChars	szFake;

	if (szName)
	{
		szFake.Fake(szName);
		return GetIndex(&szFake);
	}
	else
	{
		return INVALID_O_INDEX;
	}
}
//////////////////////////////////////////////////////////////////////////
//																		//
//																		//
//////////////////////////////////////////////////////////////////////////
CChars*	CArrayString::Add(void)
{
	CChars*		pcChars;

	pcChars = mcArray.Add();
	if (!mbFaked)
	{
		pcChars->Init();
	}
	else
	{
		pcChars->Fake(NULL);
	}
	return pcChars;
}
Example #9
0
BOOL PrivateAssertNumber(char* szExpected, CNumber* pcActual, int iLine, char* szFile)
{
	CNumber*	pcExpected;
	CChars		szExpectedAsChars;
	CChars		szActual;
	CChars		szFake;
	int			iIndex;
	short		iDecimals;
	BOOL		bResult;

	szFake.Fake(szExpected);
	iIndex = szFake.Find(0, '.');
	if (iIndex != -1)
	{
		iDecimals = (short)(szFake.Length() - iIndex);
	}
	else
	{
		iDecimals = 0;
	}

	pcExpected = gcNumberControl.Add(pcActual->mcMaxWholeNumbers, iDecimals);
	pcExpected->Init(szExpected, pcActual->mcMaxWholeNumbers, iDecimals);
	if (!pcExpected->Equals(pcActual))
	{
		pcExpected->ToString(&szExpectedAsChars);
		pcActual->ToString(&szActual);
		bResult = Fail(szExpectedAsChars.Text(), szActual.Text(), iLine, szFile);
		szExpectedAsChars.Kill();
		szActual.Kill();
	}
	else
	{
		bResult = Pass();
	}
	gcNumberControl.Remove();
	return bResult;
}
BOOL CFileUtil::FindFiles(const char*szInDirectory, BOOL bDirs, const char*szInName, const char*szExtension, CArrayChars* paszFiles, BOOL bHidden)
{
	WIN32_FIND_DATA		sFindData;
	CChars				szFindName;
	CChars				szTemp;
	HANDLE				hFindHandle;
	BOOL				bContinue;
	int					iFileExtension;
	BOOL				bValid;
	CChars				szFake;
	CChars				szDirectory;

	szDirectory.Init(szInDirectory);
	FullPath(&szDirectory);
	szFindName.Init(szDirectory);
	AppendToPath(&szFindName, "*.*");

	hFindHandle = FindFirstFile(szFindName.Text(), &sFindData);
	bContinue = (hFindHandle != INVALID_HANDLE_VALUE);

	if (!bContinue)
	{
		szDirectory.Kill();
		szFindName.Kill();
		return FALSE;
	}

	while (bContinue)
	{
		if (!(sFindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) || bHidden)
		{
			bValid = TRUE;
			if (sFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
			{
				if (bDirs)
				{
					if (szInName != NULL)
					{
						szTemp.Init(sFindData.cFileName);
						RemoveExtension(&szTemp);
						if (!szTemp.ContainsIgnoreCase(szInName))
						{
							bValid = FALSE;
						}
						szTemp.Kill();
					}
				}
				else
				{
					bValid = FALSE;
				}
			}
			else
			{
				if (!bDirs)
				{
					if (szExtension != NULL)
					{
						szFake.Fake(sFindData.cFileName);
						iFileExtension = FindExtension(szFake.Text());
						if (iFileExtension != -1)
						{
							if (!(szFake.SubStringEquals(iFileExtension+1, szExtension)))
							{
								bValid = FALSE;
							}
						}
						else
						{
							//If there is no file extension on the current file and the
							//extension being looked for is not empty...
							if (szExtension[0] != 0)
							{
								//Then this file is not valid.
								bValid = FALSE;
							}
						}
					}
					if (szInName != NULL)
					{
						szTemp.Init(sFindData.cFileName);
						RemoveExtension(&szTemp);
						if (!szTemp.ContainsIgnoreCase(szInName))
						{
							bValid = FALSE;
						}
						szTemp.Kill();
					}
				}
				else
				{
					bValid = FALSE;
				}
			}
		}
		else
		{
			bValid = FALSE;
		}

		if (bValid)
		{
			if (!((strcmp(sFindData.cFileName, ".") == 0) || (strcmp(sFindData.cFileName, "..") == 0)))
			{
				szTemp.Init(szDirectory);
				AppendToPath(&szTemp, sFindData.cFileName);
				paszFiles->Add(szTemp.Text());
				szTemp.Kill();
			}
		}

		bContinue = FindNextFile(hFindHandle, &sFindData);
	}
	FindClose(hFindHandle);

	szDirectory.Kill();
	szFindName.Kill();
	return TRUE;
}