Reading directory from CD

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
User avatar
jum
Posts: 38
Joined: Tue Apr 06, 2004 9:31 pm
Location: Cape Town
Contact:

Reading directory from CD

Post by jum »

Howdy ppl.

I'm trying to get a directory listing of the CD/CDR, using libcdvd 1.5:

strcpy(pathname, "/");

num_files = CDVD_GetDir(pathname, NULL, CDVD_GET_FILES_AND_DIRS, TocEntryList,4000, pathname);

num_files is set to the correct number of files in the root dir of the CD, however, when I try to get the actual directory entry names using:

for(i=0; i<num_files; i++)
printf("%s\n", TocEntryList.filename);

the filename is blank !!!

I've been stuck on this for literally months now, also having tried older versions of libcdvd, and the fioDopen() function.

Any help appreciated.

- jum
8 bits is all you'll ever need...
t0mb0la
Posts: 24
Joined: Tue Jan 20, 2004 5:31 pm
Location: Seattle WA, USA
Contact:

Post by t0mb0la »

Hi Jum,

Do you have TocEntryList aligned to 64 bytes?

i.e:

Code: Select all

	TocEntry TocEntryList&#91;4000&#93; __attribute__&#40;&#40;aligned&#40;64&#41;&#41;&#41;;
or

Code: Select all

 struct TocEntry *TocEntryList = &#40;struct TocEntry *&#41; memalign&#40;64, sizeof&#40;struct TocEntry&#41; * 4000&#41;;
Other than that, are you calling CDVD_FlushCache(); before CDVD_GetDir(...); ?

Can't think of any other reasons why it should be misbehaving for you.
User avatar
jum
Posts: 38
Joined: Tue Apr 06, 2004 9:31 pm
Location: Cape Town
Contact:

er...

Post by jum »

oops. aligned to 16 bytes:

struct TocEntry tocEntries[MAX_DIR_ENTRIES] __attribute__((aligned(16)));

I'll try align to 64 and use CDVD_FlushCache()

Damn, I probably says to align to 64 in the PDF manual somewhere :/

Tx tombola
8 bits is all you'll ever need...
User avatar
jum
Posts: 38
Joined: Tue Apr 06, 2004 9:31 pm
Location: Cape Town
Contact:

still doesn't work

Post by jum »

... no luck :(

No mention of aligning 64 in the PDF manual.

Strange thing is that the CDVD_GetDir() returns the correct directory/file count, but the target TocEntry struct data just doesn't get filled.

Reading a file off the CD also works OK.

Perhaps my PS2 dev setup is a bit rotten.
8 bits is all you'll ever need...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Re: Reading directory from CD

Post by J.F. »

jum wrote: strcpy(pathname, "/");

num_files = CDVD_GetDir(pathname, NULL, CDVD_GET_FILES_AND_DIRS, TocEntryList,4000, pathname);
You might be getting messed up due to the pathname. ps2menu.c uses the call above like this:
num_cd_files = CDVD_GetDir(CDpath, NULL, CDVD_GET_FILES_AND_DIRS, (void *)TocEntryList,MAX_ENTRY, NULL);
Note that they pass NULL for new_pathname. Try that with your code and see what happens.
Post Reply