WiiFlow_Lite/source/loader/fs.c
fix94.1 88955e9461 -changed the memory management yet again, now just use the mem
which has enough space left instead of fixed memory in most parts
-fixed alot of things about banner playing, now shouldnt randomly
codedump anymore or things like this, also some banner sounds
which did not play before should work fine now
-removed unused code and added better debug prints
-using some fixed voice for game banner and not always a new one
per banner
-fixed DIOS-MIOS cheats for sure now :P
-fixed possible memory allocation bug in wbfs alloc (thanks to
cfg-loader)
-removed MEM2_memalign since it did not work correctly
-fixed a few wrong memset sizes
2012-07-27 17:26:49 +00:00

45 lines
752 B
C

#include <ogcsys.h>
#include <locale.h>
#include <ogc/isfs.h>
#include <malloc.h>
#include "utils.h"
#include "fs.h"
u8 *ISFS_GetFile(u8 *path, u32 *size, s32 length)
{
*size = 0;
s32 fd = ISFS_Open((const char *)path, ISFS_OPEN_READ);
u8 *buf = NULL;
static fstats stats ATTRIBUTE_ALIGN(32);
if(fd >= 0)
{
if(ISFS_GetFileStats(fd, &stats) >= 0)
{
if(length <= 0)
length = stats.file_length;
if(length > 0)
buf = (u8 *)memalign(32, ALIGN32(length));
if(buf)
{
*size = stats.file_length;
if(ISFS_Read(fd, (char*)buf, length) != length)
{
*size = 0;
free(buf);
}
}
}
ISFS_Close(fd);
}
if (*size > 0)
{
DCFlushRange(buf, *size);
ICInvalidateRange(buf, *size);
}
return buf;
}