Files
SpaghettiKart/src/os/osPfsSearchFile.c
T
Faris Awan 5c23113592 Match/split all of libultra (#23)
* libultra from sm64 integrated; 3 libultra functions matched

* All of libultra done!

authored-by: farisawan-2000 <farisawan.2000@gmail.com>
2021-04-27 22:35:30 -06:00

51 lines
1.3 KiB
C
Executable File

#include "libultra_internal.h"
#include "controller.h"
s32 osPfsFindFile(OSPfs *pfs, u16 company_code, u32 game_code, u8 *game_name, u8 *ext_name, s32 *file_no)
{
s32 j;
int i;
__OSDir dir;
s32 ret;
int fail;
ret = 0;
PFS_CHECK_ID;
for (j = 0; j < pfs->dir_size; j++)
{
ERRCK(__osContRamRead(pfs->queue, pfs->channel, pfs->dir_table + j, (u8*)&dir));
if ((dir.company_code == company_code) && dir.game_code == game_code)
{
fail = FALSE;
if (game_name != NULL)
{
for (i = 0; i < ARRLEN(dir.game_name); i++)
{
if (dir.game_name[i] != game_name[i])
{
fail = TRUE;
break;
}
}
}
if (ext_name != NULL && !fail)
{
for (i = 0; i < ARRLEN(dir.ext_name); i++)
{
if (dir.ext_name[i] != ext_name[i])
{
fail = TRUE;
break;
}
}
}
if (!fail)
{
*file_no = j;
return ret;
}
}
}
*file_no = -1;
return PFS_ERR_INVALID;
}