Exemple #1
0
void testSavers2(ILenum type, const TCHAR* targetName, const TCHAR* targetExt)
{
	TCHAR targetFN[MAX_PATH];

	// Test ilSave
	_tcscpy(targetFN, targetName);
	_tcscat(targetFN, L".ilSave.");
	_tcscat(targetFN, targetExt);
	if (!ilSave(type, targetFN)) {
		printf("testSavers2: Failed to save " PathCharMod " using ilSave\n", targetFN);
		++errors;
	}

	// Test ilSaveF
	_tcscpy(targetFN, targetName);
	_tcscat(targetFN, L".ilSaveF.");
	_tcscat(targetFN, targetExt);
	FILE* file = _wfopen(targetFN, L"wb");
	if (!ilSaveF(type, file)) {
		printf("testSavers2: Failed to save " PathCharMod " using ilSaveF\n", targetFN);
		++errors;
	}
	fclose(file);

	// Test ilSaveL
	_tcscpy(targetFN, targetName);
	_tcscat(targetFN, L"ilSaveL.");
	_tcscat(targetFN, targetExt);
	ILuint lumpSize = ilDetermineSize(type);
	BYTE* lump = new BYTE[lumpSize];
	ILuint writtenToLump = ilSaveL(type, lump, lumpSize);
	if (writtenToLump > 0) {
		FILE* file = _wfopen(targetFN, L"wb");
		size_t writtenToFile = fwrite(lump, 1, lumpSize, file);
		if (writtenToLump != writtenToFile) {
			printf("testSavers2: Failed to write " PathCharMod " after ilSaveL\n", targetFN);
			++errors;
		}
		fclose(file);
	} else {
		printf("testSavers2: Failed to save " PathCharMod " using ilSaveL\n", targetFN);
		++errors;
	}
	delete lump;

	// Test ilSaveFuncs
	wcscpy(targetFN, targetName);
	wcscat(targetFN, L".ilSaveFuncs.");
	wcscat(targetFN, targetExt);
	writeFile = _wfopen(targetFN, L"wb");
	if (writeFile != NULL) {
		ilSetWrite(NULL, NULL, myPutc, mySeek, myTell, myWrite);
		if (!ilSaveFuncs(type))
			printf("testSavers2: Failed to save " PathCharMod " using ilSave\n", targetFN);
		fclose(writeFile);
	} else
		printf("testSavers2: Failed to open " PathCharMod " for writing\n", targetFN);
}
Exemple #2
0
ILvoid ILAPIENTRY ilResetWrite()
{
	ilSetWrite(iDefaultOpenW, iDefaultCloseW, iDefaultPutc,
				iDefaultWSeek, iDefaultWTell, iDefaultWrite);
	return;
}