Also note that im not actually writing any files with this code what minimise the possible errors.
For exemple this code will work without problem
Code: Select all
dump_filesystem("fatms0:/VSH/", "ms0:/plop/test");
Code: Select all
dump_filesystem("ms0:/IRSHELL/", "ms0:/plop/test");
Here is the main code routine :
Code: Select all
/* Build a path, append a directory slash if requested */
void build_path(char *output, const char *root, const char *path, int append)
{
while(*root != 0)
{
*output++ = *root++;
}
if(*(root-1) != '/')
{
*output++ = '/';
}
while(*path != 0)
{
*output++ = *path++;
}
if(append)
*output++ = '/';
*output++ = 0;
}
/* Dump a filing system */
void dump_filesystem(const char *root, const char *write_loc)
{
int dfd;
char next_root[256];
char next_write[256];
char mytest[512];
sceIoMkdir(write_loc, 0777);
dfd = sceIoDopen(root);
if(dfd > 0)
{
SceIoDirent dir;
while(sceIoDread(dfd, &dir) > 0)
{
if(dir.d_stat.st_attr & FIO_SO_IFDIR)
{
if(dir.d_name[0] != '.')
{
build_path(next_write, write_loc, dir.d_name, 0);
build_path(next_root, root, dir.d_name, 1);
printf("next_root is %s\n",next_root);
printf("next_write is %s\n",next_write);
dump_filesystem(next_root, next_write);
}
}
else
{
//printf("root is %s\n",root);
//printf("write_loc is %s\n",write_loc);
//printf("dir.d_name is %s\n",dir.d_name);
//write_file(root, write_loc, dir.d_name);
strcpy(mytest,"cp ");
strcat(mytest,root);
strcat(mytest,dir.d_name);
strcat(mytest," ");
strcat(mytest,write_loc);
printf("%s\n",mytest);
}
}
sceIoDclose(dfd);
}
}