I have program a function which put the names of the directories and files in a structure.
the part with the function and global variale declaration:
Code: Select all
fileinfo filelist[128];
fileinfo dirlist[128];
int dirs,files;
void getdirentrys(void){
dirs=0;
files=0;
int dfd;
SceIoDirent dir;
memset(&dir, 0, sizeof dir);
dfd = sceIoDopen("ms0:/");
while(sceIoDread(dfd, &dir)>0){
if (FIO_SO_ISREG(dir.d_stat.st_attr)){
sprintf(filelist[files].filename,"%s",dir.d_name);
files++;
}
else if (FIO_SO_ISDIR(dir.d_stat.st_attr)){
sprintf(dirlist[dirs].filename,"%s",dir.d_name);
dirs++;
}
}
sceIoClose(dfd);
}
If i put the content of this function direct into the main it works fine but that isn't practical in my situation.
This dont work:
Code: Select all
int main() {
getdirentrys();
}
Code: Select all
int main() {
dirs=0;
files=0;
int dfd;
SceIoDirent dir;
memset(&dir, 0, sizeof dir);
dfd = sceIoDopen("ms0:/");
while(sceIoDread(dfd, &dir)>0){
if (FIO_SO_ISREG(dir.d_stat.st_attr)){
sprintf(filelist[files].filename,"%s",dir.d_name);
files++;
}
else if (FIO_SO_ISDIR(dir.d_stat.st_attr)){
sprintf(dirlist[dirs].filename,"%s",dir.d_name);
dirs++;
}
}
sceIoClose(dfd);
}
Excude for my bad english.