get files and subfolders in a directory [resolved]

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

Moderators: cheriff, TyRaNiD

Post Reply
sturatt
Posts: 46
Joined: Thu Jul 13, 2006 4:21 pm

get files and subfolders in a directory [resolved]

Post by sturatt »

Can anyone help me with going about listing all the files/folders in a directory? I've searched for about an hour.. maybe I'm not searching for the rigtht thing..

I would appreciate any help.

In case this isnt clear, i just want to be able to know what files and folders are in a certian directory.
Last edited by sturatt on Sun Jul 30, 2006 4:27 am, edited 1 time in total.
the_darkside_986
Posts: 9
Joined: Tue Jul 18, 2006 3:29 pm

me too

Post by the_darkside_986 »

I'm having the same trouble finding information about this. I know it's possible because emulators do it. Maybe I should find the source for those and look. I really have an idea of a nice homebrew app that would require the ability to list and select files.
sg57
Posts: 144
Joined: Fri Oct 14, 2005 2:26 pm

Post by sg57 »

Its very simple to list all the files in a directory, but to save you the extra questions if i posted it, ill just point you to an example of a filebrowser, included with the answre you asked...

Its made by slasher, at PSPU, the thread is Slasher's dump (lol)... I faintly remember seeing a filebrowser example posted...
sturatt
Posts: 46
Joined: Thu Jul 13, 2006 4:21 pm

Post by sturatt »

hmm i figured this out a while ago, guess i should have put resolved in the title... sorry
the_darkside_986
Posts: 9
Joined: Tue Jul 18, 2006 3:29 pm

Post by the_darkside_986 »

Could someone post a link? I can't find where that is on google search.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

Code: Select all

SceIoDirent dir;
int dfd, ok;
char path[]="folder";

dfd = sceIoDopen(path);
if (dfd>=0)
{
for (;;)
{
  memset(&dir, 0, sizeof dir);
  ok = sceIoDread(dfd, &dir);
  if &#40;ok<0&#41; break;
  //extract info from dir
&#125;
sceIoDclose&#40;dfd&#41;;
&#125;
<edited: SceIoDirent>

Jim
Last edited by Jim on Tue Aug 01, 2006 8:19 am, edited 1 time in total.
the_darkside_986
Posts: 9
Joined: Tue Jul 18, 2006 3:29 pm

Post by the_darkside_986 »

Awesome thanks. But what are the members of the directory struct? I grepped the sdk/include files for sceIoDirent but couldn't find anything. I found the file that contains the prototype for sceIoDopen but that didn't help me. Am I looking in the wrong sdk folder (the one that contains pspkernel.h, pspctrl.h etc.)?
User avatar
Drakonite
Site Admin
Posts: 990
Joined: Sat Jan 17, 2004 1:30 am
Contact:

Post by Drakonite »

It's SceIoDirent, not sceIoDirent.
Shoot Pixels Not People!
Makeshift Development
Slasher
Posts: 5
Joined: Fri Jan 27, 2006 11:39 am

Post by Slasher »

http://forums.qj.net/showthread.php?p=868511#post868511

I know this is resolved, but go here and scroll down to filebrowser example. It's pretty straight forward, and should help you out.
sturatt
Posts: 46
Joined: Thu Jul 13, 2006 4:21 pm

Post by sturatt »

god, you know what i love? i post this question on the 13th... no replies for 16 days, then the only reply is someone else asking the same question... in the same thread... and gets 7 replies in 3 days -_- oh how forums love me
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

How thick does it make you feel?
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

Hehe, apparently, that's the way forums work :) Quicker replies are only to be expected on instant messengers/IRC

PS: Sometimes Murphy strikes somewhat too, but oh well, could be worse, couldn't it? :P
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
danzel
Posts: 182
Joined: Fri Nov 04, 2005 11:03 pm

Post by danzel »

That sample should have "ok<=0" instead of "ok<0". Giving you:

Code: Select all

SceIoDirent dir;
int dfd, ok;
char path&#91;&#93;="folder";

dfd = sceIoDopen&#40;path&#41;;
if &#40;dfd>=0&#41;
&#123;
	for &#40;;;&#41;
	&#123;
		memset&#40;&dir, 0, sizeof dir&#41;;
		ok = sceIoDread&#40;dfd, &dir&#41;;
		if &#40;ok<=0&#41; break;
		//extract info from dir
	&#125;
	sceIoDclose&#40;dfd&#41;;
&#125; 
Post Reply