mirror of
https://github.com/Fledge68/WiiFlow_Lite.git
synced 2024-12-24 19:01:56 +01:00
2b32db857a
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
49 lines
825 B
C
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;
|
|
}
|