[Bf-committers] Small patch to make SND_Utils more cross-platform

Stealth Apprentice stealthapprentice at yahoo.com
Sun Feb 26 08:52:09 CET 2006

Hello, SND_Utils.cpp still uses the old integer based
file handles with open, read, fseek, close...

On Visual Studio 8, this causes lots of cross-linking

Also, this code is presently #ifdef'd for windows as a
workaround for non-standard parameters for the open

This small patch below updates this function to use
fopen/fread/fseek/fclose, and eliminates ALL of the

It would be great for all the VS8 users if this could
be patched in to CVS, and it also eliminates a
platform ifdef, so it's a modest improvement, overall.


/* loads a file */
void* SND_LoadSample(char *filename)
    FILE* file;
    int filelen, buffersize = BUFFERSIZE;
	void* data = NULL;

    file = fopen(filename, "rb");

	if (file == 0)
		//printf("can't open file.\n");
		//printf("press q for quit.\n");
		filelen = fseek(file, 0, SEEK_END);
		fseek(file, 0, SEEK_SET);
		if (filelen != 0)
			data = malloc(buffersize);

			if (fread(data, 1, buffersize, file) != buffersize)
				data = NULL;
	return (data);

Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 

More information about the Bf-committers mailing list