WiiFlow_Lite/source/loader/fs.c
fix94.1 2b32db857a -removed alot of unneeded cIOS checks, saving the info about our
currently loaded cIOS instead
-fixed bug of missing remount if no games are found with enabled
NAND emulation which made wiiflow hang
-added information for neek2o
-removed ios reload on boot when wiiflow is in neek2o mode
-made NAND file extraction MEM2 only
-fixed two not free'd memory allocations which could fill the
memory with unused stuff
2012-08-11 12:27:38 +00:00

49 lines
825 B
C

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