Hi everybody!
I need a function that can print out the content of a dir (eg. ms0:/PSP/GAME/MYPROGRAM/STUFF/"). Then I want the user to be able to select one of the files/dirs in the folder (like in a menu) and then my app will copy a file from the selected dir to another dir (I already have made the copy file function).
eg. There is two folders in the "STUFF" folder called "EXTRA1" and "EXTRA2". The functions should then print out the content of the "STUFF" folder (in other words, it should print out EXTRA1 and EXTRA2) to the screen, and then the user should select one, let's say "EXTRA2". Then my copy function called copy_file is going to copy a file from the extra2 folder to another dir. eg. copy_file("ms0:/PSP/GAME/PROGRAM/STUFF/"selectedDir, "[insert a copy-to dir here]");
The selectedDir should be the Dir selected.
I hope you all understand what I mean. Thanks in advance!
Need function that can print out the content of a dir
yes this is all very easy ....search online for dir handling
dirent.h is a good start and please do finish any
standard C book :P ...as most touch upon file io
pretty much extensively ...you could also look into
the source of RIN gameboy emu that has dir handling
dirent.h is a good start and please do finish any
standard C book :P ...as most touch upon file io
pretty much extensively ...you could also look into
the source of RIN gameboy emu that has dir handling
10011011 00101010 11010111 10001001 10111010
-
- Posts: 197
- Joined: Fri Jul 01, 2005 2:50 am
Ok, this is a code snippet from my .zip extractor. It reads PSP/GAME and reads every entry into a string:
This should leave you with a list of strings, each containing a folder or file name.
Hope this helps somewhat.
Code: Select all
struct GameEntry
{
char *name;
//char ratio[16];
};
int gameEntriesTotal = 0;
int gameDirSelected = 0;
#define MAX_ENTRIES 1000
struct GameEntry gameEntry[MAX_ENTRIES];
void recacheGameDir(){
struct SceIoDirent dir;
memset(&dir, 0, sizeof(SceIoDirent));
pspDebugScreenSetXY(0,6);
//printf("Getting Directory...");
static int dfd;
dfd = sceIoDopen("ms0:/PSP/GAME/");
if(dfd > 0){
//pspDebugScreenSetXY(0,0);
//printf("Found Directory...\n");
int f=0;for(f=0;f<MAX_ENTRIES;f++){if(gameEntry[f].name){free(gameEntry[f].name);}gameEntry[f].name = NULL;}
int count = 0;count = 0;
while(sceIoDread(dfd, &dir) > 0){
static int success;
//success = sceIoDread(dfd, dir);
//if(dir){
static char* name;
name = (char*)memalign(16,300);
sprintf(name,"%s",dir.d_name);
static int s=0;
s=strlen(name);
//printf("Found: %s\n",name);
gameEntry[count].name = name;
count++;if(count>MAX_ENTRIES-1){count = MAX_ENTRIES-1;}
//printf("COUNT: %i",count);
gameEntriesTotal = count;if(gameEntriesTotal < 0){gameEntriesTotal = 0;}
}
//}
}
sceIoDclose(dfd);
//sceKernelThreadSleep(10000);
//free(&dir);
}
Hope this helps somewhat.