예제 #1
0
void TestRemoveExtension(void)
{
	CChars		szFileName;
	CFileUtil	cFileUtil;

	szFileName.Init("/mnt/world/hello.txt");
	cFileUtil.RemoveExtension(&szFileName);
	AssertString("/mnt/world/hello", szFileName.Text());

	cFileUtil.RemoveExtension(&szFileName);
	AssertString("/mnt/world/hello", szFileName.Text());
	szFileName.Kill();
}
void CImageCelsSource::AddDiskFileSources(char* szPathName, char* szFileNameContains, char* szImageName, CImageCelSource* pcCelSource)
{
	CFileUtil				cFileUtil;
	CArrayString			cFileNames;
	int						i;
	CChars*					pszName;
	CImageSourceDiskFile*	pcDiskFile;
	CChars					szNiceName;
	int						iIndex;
	int						iLen;

	if (!szFileNameContains)
	{
		return;
	}
	iLen = (int)strlen(szFileNameContains);
	if (iLen == 0)
	{
		return;
	}

	cFileNames.Init(32);
	cFileUtil.FindFilesWithNameContaining(szPathName, szFileNameContains, &cFileNames, FALSE);

	for (i = 0; i < cFileNames.NumElements(); i++)
	{
		pszName = cFileNames.Get(i);
		pcDiskFile = UMalloc(CImageSourceDiskFile);

		if (szImageName)
		{
			szNiceName.Init(*pszName);
			cFileUtil.RemovePath(&szNiceName);
			cFileUtil.RemoveExtension(&szNiceName);
			iIndex = szNiceName.Find(0, szFileNameContains);
			iIndex += iLen;
			szNiceName.RemoveFromStart(iIndex);
			szNiceName.Insert(0, szImageName);

			pcDiskFile->Init(pszName->Text(), szNiceName.Text());
			szNiceName.Kill();
		}
		else
		{
			pcDiskFile->Init(pszName->Text());
		}
		AddSource(pcDiskFile, pcCelSource);
	}

	cFileNames.Kill();
}