コード例 #1
0
ファイル: ini.c プロジェクト: Codyle/pcsx2
int INILoadString(char *file, char *section, char *keyword, char *buffer)
{
	char inname[INIMAXLEN + 1];
	int filepos;
	ACTUALHANDLE infile;
	int retval;
	if (file == NULL)  return (-1);
	if (section == NULL)  return (-1);
	if (keyword == NULL)  return (-1);
	if (buffer == NULL)  return (-1);
#ifdef VERBOSE_FUNCTION_INI
	PrintLog("CDVDiso ini: LoadString(%s, %s, %s)",
	         file, section, keyword);
#endif /* VERBOSE_FUNCTION_INI */
	filepos = INIRemoveExt(file, inname);
	INIAddInExt(inname, filepos);
	filepos = 0;
	infile = ActualFileOpenForRead(inname);
	if (infile == ACTUALHANDLENULL)  return (-1);
	retval = INIFindSection(infile, section);
	if (retval < 0) {
		ActualFileClose(infile);
		infile = ACTUALHANDLENULL;
		return (-1);
	} // ENDIF- Didn't find it? Abort.
	retval = INIFindKeyword(infile, keyword, buffer);
	if (retval < 0) {
		ActualFileClose(infile);
		infile = ACTUALHANDLENULL;
		return (-1);
	} // ENDIF- Didn't find it? Abort.
	ActualFileClose(infile);
	infile = ACTUALHANDLENULL;
	return (0);
} // END INILoadString()
コード例 #2
0
ファイル: isofile.c プロジェクト: madnessw/thesnow
struct IsoFile *IsoFileCloseAndDelete(struct IsoFile *file)
{
	int i;
	if (file == NULL)  return(NULL);
	if (file->handle != ACTUALHANDLENULL)
	{
#ifdef VERBOSE_FUNCTION_ISOFILE
		PrintLog("CDVD isofile: IsoFileCloseAndDelete()");
#endif /* VERBOSE_FUNCTION_ISOFILE */

		if (file->compress > 0)
		{
			CompressClose(file);
		}
		else
		{
			ActualFileClose(file->handle);
			file->handle = ACTUALHANDLENULL;
		} // ENDIF- Compressed File? Close (and flush) compression too.
	} // ENDIF- Open Handle? Close the file

	if (file->multi == 1)
	{
		for (i = file->multistart; i <= file->multiend; i++)
		{
			file->name[file->multipos] = '0' + i;
			ActualFileDelete(file->name);
			if (file->compress > 0)
			{
				file->tablename[file->multipos] = '0' + i;
				ActualFileDelete(file->tablename);
			} // ENDIF- Get the table file too?
		} // NEXT i- iterate through each multi-file name, removing it.
	}
	else
	{
		ActualFileDelete(file->name);
		if (file->compress > 0)
		{
			ActualFileDelete(file->tablename);
		} // ENDIF- Get the table file too?
	} // ENDIF- Do we have to remove multiple files?

	free(file);
	return(NULL);
} // END IsoFileCloseAndDelete()
コード例 #3
0
ファイル: isofile.c プロジェクト: madnessw/thesnow
struct IsoFile *IsoFileClose(struct IsoFile *file)
{
	if (file == NULL)  return(NULL);

	if (file->handle != ACTUALHANDLENULL)
	{
#ifdef VERBOSE_FUNCTION_ISOFILE
		PrintLog("CDVD isofile: IsoFileClose()");
#endif /* VERBOSE_FUNCTION_ISOFILE */
		if (file->compress > 0)
		{
			CompressClose(file);
		}
		else
		{
			ActualFileClose(file->handle);
			file->handle = ACTUALHANDLENULL;
		} // ENDIF- Compressed File? Close (and flush) compression too.
	} // ENDIF- Open Handle? Close the file
	free(file);
	return(NULL);
} // END IsoFileClose()
コード例 #4
0
ファイル: toc.c プロジェクト: Aced14/pcsx2
extern int IsoSaveTOC(struct IsoFile *isofile)
{
	char tocext[] = ".toc\0";
	char tocheader[] = "TOC1\0";
	ACTUALHANDLE tochandle;
	char tocname[256];
	int i;
	int j;
	int retval;
	unsigned char cdvdtype;
	struct tocTN toctn;
	struct tocTD toctd;
	char temptime[3];
	if (isofile == NULL)  return(-1);
	i = 0;
	while ((i < 256) && (isofile->name[i] != 0))
	{
		tocname[i] = isofile->name[i];
		i++;
	} // ENDWHILE- Copying the data name to the toc name
	j = 0;
	while ((i < 256) && (tocext[j] != 0))
	{
		tocname[i] = tocext[j];
		i++;
		j++;
	} // ENDWHILE- Append ".toc" to end of name
	tocname[i] = 0; // And 0-terminate

	ActualFileDelete(tocname);
	tochandle = ActualFileOpenForWrite(tocname);
	if (tochandle == ACTUALHANDLENULL)  return(-1);

	retval = ActualFileWrite(tochandle, 4, tocheader);
	if (retval < 4)
	{
		ActualFileClose(tochandle);
		tochandle = ACTUALHANDLENULL;
		ActualFileDelete(tocname);
		return(-1);
	} // ENDIF- Trouble writing to the 'toc' file?

	cdvdtype = isofile->cdvdtype;
	ActualFileWrite(tochandle, 1, (char *) &cdvdtype);
	if ((cdvdtype != CDVD_TYPE_PS2DVD) && (cdvdtype != CDVD_TYPE_DVDV))
	{
		toctn.strack = BCDTOHEX(isofile->toc[7]);
		toctn.etrack = BCDTOHEX(isofile->toc[17]);
		ActualFileWrite(tochandle, sizeof(struct tocTN), (char *) &toctn);
		// Leadout Data
		toctd.type = 0;
		temptime[0] = BCDTOHEX(isofile->toc[27]);
		temptime[1] = BCDTOHEX(isofile->toc[28]);
		temptime[2] = BCDTOHEX(isofile->toc[29]);
		toctd.lsn = MSFtoLBA(temptime);
		ActualFileWrite(tochandle, sizeof(struct tocTD), (char *) &toctd);
		for (i = toctn.strack; i <= toctn.etrack; i++)
		{
			j = i * 10 + 30;
			toctd.type = isofile->toc[j];
			temptime[0] = BCDTOHEX(isofile->toc[j + 7]);
			temptime[1] = BCDTOHEX(isofile->toc[j + 8]);
			temptime[2] = BCDTOHEX(isofile->toc[j + 9]);
			toctd.lsn = MSFtoLBA(temptime);
			ActualFileWrite(tochandle, sizeof(struct tocTD), (char *) &toctd);
		} // NEXT i- write out each track
	} // ENDIF- Not a DVD? (Then output CD track data)
	ActualFileClose(tochandle);
	tochandle = ACTUALHANDLENULL;
	return(0);
} // END IsoSaveTOC()
コード例 #5
0
ファイル: toc.c プロジェクト: Aced14/pcsx2
extern int IsoLoadTOC(struct IsoFile *isofile)
{
	char tocext[] = ".toc\0";
	char tocheader[5];
	ACTUALHANDLE tochandle;
	char tocname[256];
	int i;
	int j;
	int retval;
	unsigned char cdvdtype;
	struct tocTN toctn;
	struct tocTD toctd;
	if (isofile == NULL)  return(-1);
	i = 0;
	while ((i < 256) && (isofile->name[i] != 0))
	{
		tocname[i] = isofile->name[i];
		i++;
	} // ENDWHILE- Copying the data name to the toc name
	j = 0;
	while ((i < 256) && (tocext[j] != 0))
	{
		tocname[i] = tocext[j];
		i++;
		j++;
	} // ENDWHILE- Append ".toc" to end of name
	tocname[i] = 0; // And 0-terminate
	tochandle = ActualFileOpenForRead(tocname);
	if (tochandle == ACTUALHANDLENULL)  return(-1);

	retval = ActualFileRead(tochandle, 4, tocheader);
	if (retval < 4)
	{
		ActualFileClose(tochandle);
		tochandle = ACTUALHANDLENULL;
		return(-1);
	} // ENDIF- Trouble reading the 'toc' file?
	if ((tocheader[0] != 'T') ||
	        (tocheader[1] != 'O') ||
	        (tocheader[2] != 'C') ||
	        (tocheader[3] != '1'))
	{
		ActualFileClose(tochandle);
		tochandle = ACTUALHANDLENULL;
		return(-1);
	} // ENDIF- Not a 'toc' file after all?
#ifdef VERBOSE_FUNCTION_TOC
	PrintLog("CDVDiso TOC: IsoLoadTOC(%s)", tocname);
#endif /* VERBOSE_FUNCTION_TOC */
	retval = ActualFileRead(tochandle, 1, (char *) & cdvdtype);
	if (retval < 1)
	{
		ActualFileClose(tochandle);
		tochandle = ACTUALHANDLENULL;
		return(-1);
	} // ENDIF- Trouble reading the 'toc' file?
	isofile->cdvdtype = cdvdtype;
	IsoInitTOC(isofile);

	if ((cdvdtype != CDVD_TYPE_PS2DVD) && (cdvdtype != CDVD_TYPE_DVDV))
	{
		retval = ActualFileRead(tochandle, sizeof(struct tocTN), (char *) & toctn);
		if (retval < sizeof(struct tocTN))
		{
			ActualFileClose(tochandle);
			tochandle = ACTUALHANDLENULL;
			return(-1);
		} // ENDIF- Trouble reading the 'toc' file?

		if ((toctn.strack > 99) || (toctn.etrack > 99))
		{
			ActualFileClose(tochandle);
			tochandle = ACTUALHANDLENULL;
			return(-1);
		} // ENDIF- Track numbers out of range?
#ifdef VERBOSE_FUNCTION_TOC
		PrintLog("CDVDiso TOC:   Start Track %u   End Track %u",
		         toctn.strack, toctn.etrack);
#endif /* VERBOSE_FUNCTION_TOC */
		IsoAddTNToTOC(isofile, toctn);
		retval = ActualFileRead(tochandle, sizeof(struct tocTD), (char *) & toctd);
		if (retval < sizeof(struct tocTD))
		{
			ActualFileClose(tochandle);
			tochandle = ACTUALHANDLENULL;
			return(-1);
		} // ENDIF- Trouble reading the 'toc' file?
		if (toctd.type != 0)
		{
			ActualFileClose(tochandle);
			tochandle = ACTUALHANDLENULL;
			return(-1);
		} // ENDIF- Track numbers out of range?
#ifdef VERBOSE_FUNCTION_TOC
		PrintLog("CDVDiso TOC:   Total Sectors: %lu", toctd.lsn);
#endif /* VERBOSE_FUNCTION_TOC */
		IsoAddTDToTOC(isofile, 0xAA, toctd);
		for (i = toctn.strack; i <= toctn.etrack; i++)
		{
			retval = ActualFileRead(tochandle, sizeof(struct tocTD), (char *) & toctd);
			if (retval < sizeof(struct tocTD))
			{
				ActualFileClose(tochandle);
				tochandle = ACTUALHANDLENULL;
				return(-1);
			} // ENDIF- Trouble reading the 'toc' file?
#ifdef VERBOSE_FUNCTION_TOC
			PrintLog("CDVDiso TOC:   Track %u  Type %u  Sector Start: %lu",
			         i, toctd.type, toctd.lsn);
#endif /* VERBOSE_FUNCTION_TOC */
			IsoAddTDToTOC(isofile, i, toctd);
		} // NEXT i- read in each track
	} // ENDIF- Not a DVD? (Then read in CD track data)
	ActualFileClose(tochandle);
	tochandle = ACTUALHANDLENULL;
	return(0);
} // END IsoLoadTOC()
コード例 #6
0
ファイル: isofile.c プロジェクト: madnessw/thesnow
struct IsoFile *IsoFileOpenForWrite(const char *filename,
			                                    int imagetype,
			                                    int multi,
			                                    int compress)
{
	struct IsoFile *newfile;

	newfile = NULL;

	if (filename == NULL)  return(NULL);
	if ((imagetype < 0) || (imagetype > 11))  return(NULL);
	if ((compress < 0) || (compress > 5))  return(NULL);

#ifdef VERBOSE_FUNCTION_ISOFILE
	PrintLog("CDVD isofile: IsoFileOpenForWrite()");
#endif /* VERBOSE_FUNCTION_ISOFILE */

	newfile = (struct IsoFile *) malloc(sizeof(struct IsoFile));
	if (newfile == NULL)  return(NULL);
	newfile->sectorpos = 0;
	newfile->openforread = 0; // Write-only file
	newfile->filebytesize = 0;
	newfile->filebytepos = 0;
	newfile->filesectorsize = 0;
	newfile->filesectorpos = 0;

	// if(toc != NULL) {
	//   for(i = 0; i < 2048; i++)  newfile->toc[i] = *(toc + i);
	// } else {
	//   for(i = 0; i < 2048; i++)  newfile->toc[i] = 0;
	// } // ENDIF- Do we have a PS2 Table of Contents to save out as well?

	newfile->namepos = 0;
	while ((newfile->namepos < 255) &&
	        (*(filename + newfile->namepos) != 0))
	{
		newfile->name[newfile->namepos] = *(filename + newfile->namepos);
		newfile->namepos++;
	} // ENDWHILE- copying the file name in...
	newfile->name[newfile->namepos] = 0; // And 0-terminate.

	IsoNameStripExt(newfile);
	IsoNameStripCompress(newfile);
	IsoNameStripExt(newfile);
	IsoNameStripMulti(newfile);
	newfile->name[newfile->namepos] = 0; // And 0-terminate.

	newfile->imagetype = imagetype;
	GetImageType(newfile, imagetype);
	newfile->cdvdtype = CDVD_TYPE_PS2DVD; // Does it matter here? Nope.

	newfile->multi = multi;
	if (newfile->multi > 0)
	{
		newfile->name[newfile->namepos + 0] = '-';
		newfile->name[newfile->namepos + 1] = 'I';
		newfile->name[newfile->namepos + 2] = '0';
		newfile->name[newfile->namepos + 3] = '0';
		newfile->name[newfile->namepos + 4] = 0;
		newfile->multipos = newfile->namepos + 3;
		newfile->namepos += 4;
		newfile->multistart = 0;
		newfile->multiend = 0;
		newfile->multinow = 0;
		newfile->multioffset = 0;
		newfile->multisectorend[0] = 0;
	} // ENDIF- Are we creating a multi-file?

	newfile->compress = compress;
	switch (newfile->compress)
	{
		case 1:
		case 3:
			newfile->name[newfile->namepos + 0] = '.';
			newfile->name[newfile->namepos + 1] = 'Z';
			newfile->name[newfile->namepos + 2] = 0;
			newfile->namepos += 2;
			break;

		case 2:
			newfile->name[newfile->namepos + 0] = '.';
			newfile->name[newfile->namepos + 1] = 'd';
			newfile->name[newfile->namepos + 2] = 'u';
			newfile->name[newfile->namepos + 3] = 'm';
			newfile->name[newfile->namepos + 4] = 'p';
			newfile->name[newfile->namepos + 5] = 0;
			newfile->namepos += 5;
			break;

		case 4:
			newfile->name[newfile->namepos + 0] = '.';
			newfile->name[newfile->namepos + 1] = 'B';
			newfile->name[newfile->namepos + 2] = 'Z';
			newfile->name[newfile->namepos + 3] = '2';
			newfile->name[newfile->namepos + 4] = 0;
			newfile->namepos += 4;
			break;
		case 5:
			newfile->name[newfile->namepos + 0] = '.';
			newfile->name[newfile->namepos + 1] = 'b';
			newfile->name[newfile->namepos + 2] = 'z';
			newfile->name[newfile->namepos + 3] = '2';
			newfile->name[newfile->namepos + 4] = 0;
			newfile->namepos += 4;
			break;

		case 0:
		default:
			break;
	} // ENDSWITCH compress- which compression extension should we add on?
	newfile->name[newfile->namepos + 0] = '.';
	newfile->name[newfile->namepos + 4] = 0;
	if (newfile->blocksize == 2048)
	{
		newfile->name[newfile->namepos + 1] = 'i';
		newfile->name[newfile->namepos + 2] = 's';
		newfile->name[newfile->namepos + 3] = 'o';
	}
	else
	{
		newfile->name[newfile->namepos + 1] = 'b';
		newfile->name[newfile->namepos + 2] = 'i';
		newfile->name[newfile->namepos + 3] = 'n';
	} // ENDIF- Is this a true ISO (or just a raw BIN file?)
	newfile->namepos += 4;

	if (IsActualFile(newfile->name) == 0)
	{
		free(newfile);
		newfile = NULL;
		return(NULL);
	} // ENDIF- Does the destination file already exist?

	if (newfile->compress > 0)
	{
		CompressOpenForWrite(newfile);
		if ((newfile->handle != ACTUALHANDLENULL) &&
		        (newfile->tablehandle == ACTUALHANDLENULL))
		{
			ActualFileClose(newfile->handle);
			newfile->handle = ACTUALHANDLENULL;
		} // ENDIF Data file created, but table file stopped? Close and remove data
	}
	else
	{
		newfile->handle = ActualFileOpenForWrite(newfile->name);
	} // ENDIF- Writing out a compressed file?
	if (newfile->handle == ACTUALHANDLENULL)
	{
		free(newfile);
		newfile = NULL;
		return(NULL);
	} // ENDIF- Couldn't create file? Abort
	return(newfile);
} // END IsoFileOpenForWrite()
コード例 #7
0
ファイル: ini.c プロジェクト: Codyle/pcsx2
int INIRemove(char *file, char *section, char *keyword)
{
	char inname[INIMAXLEN + 1];
	char outname[INIMAXLEN + 1];
	int filepos;
	ACTUALHANDLE infile;
	ACTUALHANDLE outfile;
	char templine[INIMAXLEN + 1];
	int i;
	int retval;
	if (file == NULL)  return (-1);
	if (section == NULL)  return (-1);
#ifdef VERBOSE_FUNCTION_INI
	PrintLog("CDVDiso ini: Remove(%s, %s, %s)",
	         file, section, keyword);
#endif /* VERBOSE_FUNCTION_INI */
	filepos = INIRemoveExt(file, inname);
	for (i = 0; i <= filepos; i++)  outname[i] = inname[i];
	INIAddInExt(inname, filepos);
	INIAddOutExt(outname, filepos);
	infile = ActualFileOpenForRead(inname);
	if (infile == ACTUALHANDLENULL)  return (-1);
	retval = INIFindSection(infile, section);
	if (retval == -1) {
		ActualFileClose(infile);
		infile = ACTUALHANDLENULL;
		return (-1);
	} // ENDIF- Couldn't even find the section? Abort
	filepos = retval;
	if (keyword == NULL) {
#ifdef VERBOSE_FUNCTION_INI
		PrintLog("CDVDiso ini:   removing section");
#endif /* VERBOSE_FUNCTION_INI */
		outfile = ActualFileOpenForWrite(outname);
		if (outfile == ACTUALHANDLENULL) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			return (-1);
		} // ENDIF- Couldn't open a temp file? Abort
		ActualFileSeek(infile, 0);
		retval = INICopy(infile, outfile, filepos);
		if (retval > 0) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			ActualFileClose(outfile);
			outfile = ACTUALHANDLENULL;
			ActualFileDelete(outname);
			return (-1);
		} // ENDIF- Trouble writing everything up to the section? Abort.
		templine[0] = 0;
		retval = 1;
		while ((retval > 0) && (templine[0] != '['))
			retval = INIReadLine(infile, templine); // ENDWHILE- Read to the start of the next section... or EOF.
		if (templine[0] == '[') {
			i = 0;
			while ((i < INIMAXLEN) && (templine[i] != 0)) i++;
			retval = ActualFileWrite(outfile, i, templine);
			if (retval < i) {
				ActualFileClose(infile);
				infile = ACTUALHANDLENULL;
				ActualFileClose(outfile);
				outfile = ACTUALHANDLENULL;
				ActualFileDelete(outname);
				return (-1);
			} // ENDIF- Trouble writing it out? Abort.
		} // ENDIF- Are there other sections after this one? Save them then.
	} else {
		filepos = retval;
		ActualFileSeek(infile, filepos);
		filepos += INIReadLine(infile, templine); // Get section line's byte count
		retval = INIFindKeyword(infile, keyword, NULL);
		if (retval == -1) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			return (-1);
		} // ENDIF- Couldn't find the keyword? Abort
		filepos += retval;
#ifdef VERBOSE_FUNCTION_INI
		PrintLog("CDVDiso ini:   removing keyword");
#endif /* VERBOSE_FUNCTION_INI */
		outfile = ActualFileOpenForWrite(outname);
		if (outfile == ACTUALHANDLENULL) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			return (-1);
		} // ENDIF- Couldn't open a temp file? Abort
		ActualFileSeek(infile, 0);
		retval = INICopy(infile, outfile, filepos);
		if (retval > 0) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			ActualFileClose(outfile);
			outfile = ACTUALHANDLENULL;
			ActualFileDelete(outname);
			return (-1);
		} // ENDIF- Trouble writing everything up to keyword? Abort.
		INIReadLine(infile, templine); // Read (and discard) the keyword line
	} // ENDIF- Wipe out the whole section? Or just a keyword?
	INICopy(infile, outfile, 0xFFFFFFF); // Write out rest of file
	ActualFileClose(infile);
	infile = ACTUALHANDLENULL;
	ActualFileClose(outfile);
	outfile = ACTUALHANDLENULL;
	ActualFileDelete(inname);
	ActualFileRename(outname, inname);
	return (0);
} // END INIRemove()
コード例 #8
0
ファイル: ini.c プロジェクト: Codyle/pcsx2
int INISaveString(char *file, char *section, char *keyword, char *value)
{
	char inname[INIMAXLEN + 1];
	char outname[INIMAXLEN + 1];
	int filepos;
	ACTUALHANDLE infile;
	ACTUALHANDLE outfile;
	int i;
	int retval;
	char templine[INIMAXLEN + 1];
	if (file == NULL)  return (-1);
	if (section == NULL)  return (-1);
	if (keyword == NULL)  return (-1);
	if (value == NULL)  return (-1);
#ifdef VERBOSE_FUNCTION_INI
	PrintLog("CDVDiso ini: SaveString(%s, %s, %s, %s)",
	         file, section, keyword, value);
#endif /* VERBOSE_FUNCTION_INI */
	filepos = INIRemoveExt(file, inname);
	for (i = 0; i <= filepos; i++)  outname[i] = inname[i];
	INIAddInExt(inname, filepos);
	INIAddOutExt(outname, filepos);
	filepos = 0;
	infile = ActualFileOpenForRead(inname);
	if (infile == ACTUALHANDLENULL) {
#ifdef VERBOSE_FUNCTION_INI
		PrintLog("CDVDiso ini:   creating new file");
#endif /* VERBOSE_FUNCTION_INI */
		outfile = ActualFileOpenForWrite(inname);
		if (outfile == ACTUALHANDLENULL)  return (-1); // Just a bad name? Abort.
		sprintf(templine, "[%s]\r\n", section);
		i = 0;
		while ((i < INIMAXLEN) && (templine[i] != 0)) i++;
		retval = ActualFileWrite(outfile, i, templine);
		if (retval < i) {
			ActualFileClose(outfile);
			outfile = ACTUALHANDLENULL;
			ActualFileDelete(inname);
			return (-1);
		} // ENDIF- Trouble writing it out? Abort.
		sprintf(templine, "%s=%s\r\n", keyword, value);
		i = 0;
		while ((i < INIMAXLEN) && (templine[i] != 0)) i++;
		retval = ActualFileWrite(outfile, i, templine);
		ActualFileClose(outfile);
		outfile = ACTUALHANDLENULL;
		if (retval < i) {
			ActualFileDelete(inname);
			return (-1);
		} // ENDIF- Trouble writing it out? Abort.
		return (0);
	} // ENDIF- No input file? Create a brand new .ini file then.
	retval = INIFindSection(infile, section);
	if (retval < 0) {
#ifdef VERBOSE_FUNCTION_INI
		PrintLog("CDVDiso ini:   creating new section");
#endif /* VERBOSE_FUNCTION_INI */
		outfile = ActualFileOpenForWrite(outname);
		if (outfile == ACTUALHANDLENULL) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			return (-1);
		} // ENDIF- Couldn't open a temp file? Abort
		ActualFileSeek(infile, 0); // Move ini to beginning of file...
		INICopy(infile, outfile, 0x0FFFFFFF); // Copy the whole file out...
		sprintf(templine, "\r\n[%s]\r\n", section);
		i = 0;
		while ((i < INIMAXLEN) && (templine[i] != 0)) i++;
		retval = ActualFileWrite(outfile, i, templine);
		if (retval < i) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			ActualFileClose(outfile);
			outfile = ACTUALHANDLENULL;
			ActualFileDelete(outname);
			return (-1);
		} // ENDIF- Trouble writing it out? Abort.
		sprintf(templine, "%s=%s\r\n", keyword, value);
		i = 0;
		while ((i < INIMAXLEN) && (templine[i] != 0)) i++;
		retval = ActualFileWrite(outfile, i, templine);
		ActualFileClose(infile);
		infile = ACTUALHANDLENULL;
		ActualFileClose(outfile);
		outfile = ACTUALHANDLENULL;
		if (retval < i) {
			ActualFileDelete(outname);
			return (-1);
		} // ENDIF- Trouble writing it out? Abort.
		ActualFileDelete(inname);
		ActualFileRename(outname, inname);
		return (0);
	} // ENDIF- Couldn't find the section? Make a new one!
	filepos = retval;
	ActualFileSeek(infile, filepos);
	filepos += INIReadLine(infile, templine); // Get section line's byte count
	retval = INIFindKeyword(infile, keyword, NULL);
	if (retval < 0) {
#ifdef VERBOSE_FUNCTION_INI
		PrintLog("CDVDiso ini:   creating new keyword");
#endif /* VERBOSE_FUNCTION_INI */
		ActualFileSeek(infile, filepos);
		retval = INIReadLine(infile, templine);
		i = 0;
		while ((i < INIMAXLEN) && (templine[i] != 0) && (templine[i] != '='))  i++;
		while ((retval > 0) && (templine[i] == '=')) {
			filepos += retval;
			retval = INIReadLine(infile, templine);
			i = 0;
			while ((i < INIMAXLEN) && (templine[i] != 0) && (templine[i] != '='))  i++;
		} // ENDWHILE- skimming to the bottom of the section
		outfile = ActualFileOpenForWrite(outname);
		if (outfile == ACTUALHANDLENULL) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			return (-1);
		} // ENDIF- Couldn't open a temp file? Abort
		ActualFileSeek(infile, 0);
		retval = INICopy(infile, outfile, filepos);
		if (retval > 0) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			ActualFileClose(outfile);
			outfile = ACTUALHANDLENULL;
			ActualFileDelete(outname);
			return (-1);
		} // ENDIF- Trouble writing everything up to keyword? Abort.
		sprintf(templine, "%s=%s\r\n", keyword, value);
		i = 0;
		while ((i < INIMAXLEN) && (templine[i] != 0)) i++;
		retval = ActualFileWrite(outfile, i, templine);
		if (retval < i) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			ActualFileClose(outfile);
			outfile = ACTUALHANDLENULL;
			ActualFileDelete(outname);
			return (-1);
		} // ENDIF- Trouble writing it out? Abort.
	} else {
#ifdef VERBOSE_FUNCTION_INI
		PrintLog("CDVDiso ini:   replacing keyword");
#endif /* VERBOSE_FUNCTION_INI */
		filepos += retval; // Position just before old version of keyword
		outfile = ActualFileOpenForWrite(outname);
		if (outfile == ACTUALHANDLENULL) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			return (-1);
		} // ENDIF- Couldn't open a temp file? Abort
		ActualFileSeek(infile, 0);
		retval = INICopy(infile, outfile, filepos);
		if (retval > 0) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			ActualFileClose(outfile);
			outfile = ACTUALHANDLENULL;
			ActualFileDelete(outname);
			return (-1);
		} // ENDIF- Trouble writing everything up to keyword? Abort.
		INIReadLine(infile, templine); // Read past old keyword/value...
		// Replace with new value
		sprintf(templine, "%s=%s\r\n", keyword, value);
		i = 0;
		while ((i < INIMAXLEN) && (templine[i] != 0)) i++;
		retval = ActualFileWrite(outfile, i, templine);
		if (retval < i) {
			ActualFileClose(infile);
			infile = ACTUALHANDLENULL;
			ActualFileClose(outfile);
			outfile = ACTUALHANDLENULL;
			ActualFileDelete(outname);
			return (-1);
		} // ENDIF- Trouble writing it out? Abort.
	} // ENDIF- Need to add a new keyword?
	INICopy(infile, outfile, 0xFFFFFFF); // Write out rest of file
	ActualFileClose(infile);
	infile = ACTUALHANDLENULL;
	ActualFileClose(outfile);
	outfile = ACTUALHANDLENULL;
	ActualFileDelete(inname);
	ActualFileRename(outname, inname);
	return (0);
} // END INISaveString()