view LightClone/Source/Util.cpp @ 33:06b151afc8d0

Cleaned up UI art; Completed drag and drop; Centered grid
author koryspansel <koryspansel@bendbroadband.com>
date Wed, 21 Sep 2011 00:50:20 -0700
parents 7e3a0ae9c016
children 00d17d8f407d
line wrap: on
line source

/*
 * Util
 */

#include "Util.h"
#include <stdio.h>

/*
 * LoadFile
 */
Buffer LoadFile(const char* pName)
{
	uint8* pData = NULL;
	uint32 nSize = 0;

	FILE* pFile = NULL;
	if(fopen_s(&pFile, pName, "rt") == 0)
	{
		fseek(pFile, 0, SEEK_END);
		nSize = (uint32)ftell(pFile);
		fseek(pFile, 0, SEEK_SET);

		if(nSize > 0)
		{
			pData = new uint8[nSize];

			uint32 nCount = (uint32)fread(pData, sizeof(uint8), nSize, pFile);
			if(nCount != nSize)
			{
				delete[] pData;

				pData = NULL;
				nSize = 0;
			}
		}

		fclose(pFile);
	}

	return Buffer(pData, nSize);
}