Hola,
Aunque no he realizado codigo desde cero, revisando en varios emuladores me encontre una llamada para obtener el listado de archivos. Se llama sceIoDread().
Ya con ello puedes revisar la siguiente url:
http://forums.psp-hacks.com/archive/index.php/t-213353.htmlSi te sirve, en el codigo fuente de los emuladores CPS1, CPS2 Y MVS se encuentra la siguiente función dentro del archivo filer.c . No es el ejemplo mas simple, pero te puede dar una idea.
Saludos.
static void getDir(const char *path)
{
int i, j, type, fd;
memset(&dir, 0, sizeof(dir));
nfiles = 0;
if (strcmp(path, "ms0:/") != 0)
{
strcpy(files[nfiles]->name, "..");
strcpy(files[nfiles]->title, "..");
files[nfiles]->type = FTYPE_UPPERDIR;
files[nfiles]->flag = 0;
nfiles++;
}
fd = sceIoDopen(path);
while (nfiles < MAX_ENTRY)
{
char *ext;
if (sceIoDread(fd, &dir) <= 0)
{
break;
}
if (dir.d_name[0] == '.')
{
continue;
}
if ((ext = strrchr(dir.d_name, '.')) != NULL)
{
if (stricmp(ext, ".zip") == 0)
{
strcpy(files[nfiles]->name, dir.d_name);
files[nfiles]->type = FTYPE_ZIP;
if (set_file_flags(path, nfiles))
{
nfiles++;
}
continue;
}
}
if (dir.d_stat.st_attr == FIO_SO_IFDIR)
{
if (stricmp(dir.d_name, "config") == 0) continue;
if (stricmp(dir.d_name, "snap") == 0) continue;
if (stricmp(dir.d_name, "nvram") == 0) continue;
strcpy(files[nfiles]->name, dir.d_name);
files[nfiles]->type = FTYPE_DIR;
set_file_flags(path, nfiles);
nfiles++;
}
}
sceIoDclose(fd);
for (i = 0; i < nfiles - 1; i++)
{
for (j = i + 1; j < nfiles; j++)
{
if (files[i]->type > files[j]->type)
{
struct dirent tmp;
tmp = *files[i];
*files[i] = *files[j];
*files[j] = tmp;
}
}
}
for (type = 1; type < 4; type++)
{
int start = nfiles, end = 0;
for (i = 0; i < nfiles; i++)
{
if (files[i]->type == type)
{
start = i;
break;
}
}
for (; i < nfiles; i++)
{
if (files[i]->type != type)
{
end = i;
break;
}
}
if (start == nfiles) continue;
if (end == 0) end = nfiles;
for (i = start; i < end - 1; i++)
{
for (j = i + 1; j < end; j++)
{
if (strcmp(files[i]->title, files[j]->title) > 0)
{
struct dirent tmp;
tmp = *files[i];
*files[i] = *files[j];
*files[j] = tmp;
}
}
}
}
}