what happened to diropen, dirnext & dirclose?

Support for the GBA/DS/Gamecube/Wii media card library
Post Reply
sverx
Posts: 94
Joined: Wed Aug 12, 2009 2:56 pm
Location: github.com/sverx
Contact:

what happened to diropen, dirnext & dirclose?

Post by sverx » Mon Apr 23, 2012 1:03 pm

I tried to compile a, well, not-so old project of mine and it returns

Code: Select all

c:/.../main.c:82: undefined reference to `diropen'
c:/.../main.c:89: undefined reference to `dirnext'
c:/.../main.c:102: undefined reference to `dirclose'
:o
Any hint? Where did they disappear?

elhobbs
Posts: 352
Joined: Thu Jul 02, 2009 1:19 pm

Re: what happened to diropen, dirnext & dirclose?

Post by elhobbs » Mon Apr 23, 2012 1:38 pm

you should use opendir, readdir, and closedir. I think that diropen, etc. are non standard.

sverx
Posts: 94
Joined: Wed Aug 12, 2009 2:56 pm
Location: github.com/sverx
Contact:

Re: what happened to diropen, dirnext & dirclose?

Post by sverx » Mon Apr 23, 2012 2:47 pm

I see. BTW I was using those because I saw them in the examples on the chishm libfat page... :? (and they were working until... somewhen 2011...)

I rewrote that code part using this example on libnds documentation website anyway.

Thanks! :)

elhobbs
Posts: 352
Joined: Thu Jul 02, 2009 1:19 pm

Re: what happened to diropen, dirnext & dirclose?

Post by elhobbs » Mon Apr 23, 2012 4:27 pm

IIRC there were some stability issues with diropen - different struct size or something along those lines - probably a thread on it if you care to search. instead of fixing it, they were dropped for the C standard versions.

WinterMute
Site Admin
Posts: 1385
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: what happened to diropen, dirnext & dirclose?

Post by WinterMute » Mon Apr 23, 2012 9:11 pm

There wasn't a way to fix them, the functions were dependent on the programmer supplying a large enough buffer and apparently nobody was capable of doing that. The API would have needed to change to make the functions safer so I decided we'd be better off using standard functions instead.
Help keep devkitPro toolchains free, Donate today

devkitPro IRC support
Personal Blog

sverx
Posts: 94
Joined: Wed Aug 12, 2009 2:56 pm
Location: github.com/sverx
Contact:

Re: what happened to diropen, dirnext & dirclose?

Post by sverx » Mon Apr 23, 2012 9:38 pm

WinterMute wrote:[...] the functions were dependent on the programmer supplying a large enough buffer and apparently nobody was capable of doing that [...]
You mean this? (taken again from chishm's libfat page)

Code: Select all

char filename[MAXPATHLEN]; // always guaranteed to be enough to hold a filename

WinterMute
Site Admin
Posts: 1385
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: what happened to diropen, dirnext & dirclose?

Post by WinterMute » Mon Apr 23, 2012 10:53 pm

yeah, apparently people are incapable of using that, I have bug reports in my inbox with people using 256, 512, 1024, NAME_MAX, PATH_MAX, FILENAME_MAX ...

Then there's stuff like this - MAXPATHLEN isn't actually guaranteed to hold a full path, it's merely an arbitrary maximum.

https://bugzilla.mozilla.org/show_bug.cgi?id=412610

In the end, the dir* functions were non standard so it seemed better to remove them in favour of more standard, portable code.
Help keep devkitPro toolchains free, Donate today

devkitPro IRC support
Personal Blog

sverx
Posts: 94
Joined: Wed Aug 12, 2009 2:56 pm
Location: github.com/sverx
Contact:

Re: what happened to diropen, dirnext & dirclose?

Post by sverx » Tue Apr 24, 2012 9:39 am

WinterMute wrote: [...] MAXPATHLEN isn't actually guaranteed to hold a full path, it's merely an arbitrary maximum. [...]
I see. BTW file names (not full paths) shouldn't be longer than 255 UTF-16 chars, which I believe cannot be longer than 255*2*2... so 1024 shouldn't give any problem... at least I never had any problem/bug report with my XM7Play XM/MOD Player, which used the aforementioned functions and char array... :roll:

BTW... thanks :)

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests