Page 1 of 1

Reading directory from CD

Posted: Wed May 26, 2004 5:15 pm
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

Posted: Thu May 27, 2004 1:42 pm
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.

er...

Posted: Sat May 29, 2004 6:37 am
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

still doesn't work

Posted: Sat May 29, 2004 8:32 pm
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.

Re: Reading directory from CD

Posted: Sun May 30, 2004 8:29 am
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.