Пример #1
0
/**
 * Reads the whole file in the memory.
 *
 * @param filename The name of the file to open.
 * @param mallocFlags The type of memory to allocate.
 * @return The CS:IP of the allocated memory where the file has been read.
 */
void *File_ReadWholeFile(const char *filename)
{
	uint8 index;
	uint32 length;
	void *buffer;

	index = File_Open(filename, 1);
	length = File_GetSize(index);

	buffer = malloc(length + 1);
	File_Read(index, buffer, length);

	/* In case of text-files it can be very important to have a \0 at the end */
	((char *)buffer)[length] = '\0';

	File_Close(index);

	return buffer;
}
Пример #2
0
sProfilerHeader	*	Profiler_LoadProfile( char * apFileName )
{
	sProfilerHeader *	lpHeader;
	S32					lSize;

	lSize = File_GetSize( apFileName );
	if( lSize < sizeof(sProfilerHeader ) )
	{
		return( 0 );
	}

	lpHeader = File_Load( apFileName );
	if( lpHeader )
	{
		lSize -= sizeof(sProfilerHeader);
		lpHeader->EntryCount = lSize >> 2L;
	}

	return( lpHeader );
}
Пример #3
0
/**
 * ??.
 * @param filename The name of the file to load.
 * @return Where the file is loaded.
 */
void *Sound_Unknown0823(const char *filename, uint32 *retFileSize)
{
    uint8 fileIndex;
    uint32 fileSize;
    void *res;

    if (filename == NULL || !File_Exists(filename)) return NULL;

    fileIndex = File_Open(filename, 1);
    fileSize  = File_GetSize(fileIndex);
    File_Close(fileIndex);

    fileSize += 1;
    fileSize &= 0xFFFFFFFE;

    *retFileSize = fileSize;
    res = malloc(fileSize);
    Driver_Voice_LoadFile(filename, res, fileSize);

    return res;
}
Пример #4
0
int File::GetSize() { return file ? File_GetSize(file) : 0; }