Recursive function to get absolute path of all file in a dir

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Recursive function to get absolute path of all file in a dir

Post by ne0h »

I have to copy a entire directory, but i'm not been able to write a function to get all the file in a directory and subdirectory,
has anyone write a similar function?
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

If only your ability to click 'New Topic' was as good as your ability to click 'Search'...

This is for recursively deleting, but is the same idea: http://forums.ps2dev.org/viewtopic.php?t=6859
Pirata Nervo
Posts: 409
Joined: Tue Oct 09, 2007 4:22 am

Post by Pirata Nervo »

LOL @ IWN
Image
Upgrade your PSP
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

Tanks, but there is to include specific library? what is newlib?
And i use the first or the second function?

Code: Select all

memset(&dirent, 0, sizeof dirent);
Where i'have tu put this in the second function ( if with this is perfect ).
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

The function of pspwill will not work correcly!
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

ne0h.

http://www.cprogramming.com/

You're like the spotty teenager at the prom asking the lead cheerleader for a dance.

Way out of your league.

Learn to program, then apply that knowledge to the PSP.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Insert_witty_name wrote:ne0h.

http://www.cprogramming.com/

You're like the spotty teenager at the prom asking the lead cheerleader for a dance.

Way out of your league.

Learn to program, then apply that knowledge to the PSP.
Okay, this is going into my quotes file. I only aspire to this level of greatness in responding to noobs. :D
angelo
Posts: 168
Joined: Wed Aug 29, 2007 9:34 pm

Post by angelo »

Okay, this is going into my quotes file. I only aspire to this level of greatness in responding to noobs. :D
...and the odd team member... =P
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

uff...
Can you do anything then kidding me?
If i do this question in other forums i've no response because this is not a forum to discute about the PSP programming!
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

I've resolved, excuse me for the post before...
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

I've writed the function for copy a entire directory, but it will creat a empty file with the name of directory, not a directory, this is the funct:

Code: Select all

//------- fileDest="ms0:/PSP/GAME"

//------- fileSrc="ms0:/ISO"

sceIoMkdir(fileDest, PSP_O_RDWR);

Copydir(fileSrc, fileDest);
and the Copydir funct:

Code: Select all

void Copydir(char *dir, char* destination)
{
 int fd;
 SceIoDirent dirent;
 fd = sceIoDopen(dir);
 char fullname[512];
 char dest[512];
 memset(&dirent, 0, sizeof dirent);
 while (sceIoDread(fd, &dirent) > 0)
 {
  sprintf(fullname, "%s/%s", dir, dirent.d_name);
  sprintf(dest, "%s/%s", destination, dirent.d_name);
  if ((FIO_S_IFREG & (dirent.d_stat.st_mode & FIO_S_IFMT)) == 0)
      {
             sceIoMkdir(dest, PSP_O_RDWR);
             Copydir(fullname, dest);
         }
  else
      {
      fileCopy(fullname, dest);
      }
  }
 sceIoDclose(fd);
}
When i create a dir with sceIoMkdir, can i put a absoluto path? or i must put only the name?
pspZorba
Posts: 156
Joined: Sat Sep 22, 2007 11:45 am
Location: NY

Post by pspZorba »

When i create a dir with sceIoMkdir, can i put a absoluto path? or i must put only the name?

You can just try ...

... in place of asking, you will have a faster answer, and people will continue to help you,

With this kind of question that you can check by yourself, you make people unwilling to help you.
--pspZorba--
NO to K1.5 !
ne0h
Posts: 386
Joined: Thu Feb 21, 2008 2:15 am

Post by ne0h »

i've tryed but I haven't find the error, and then i've ask...
However, i've resolved!
Post Reply