gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > libfat / no$gba / fopen() always fails

#161422 - ZeroSum - Sun Aug 03, 2008 4:27 am

I've used this post to setup my build so I can test libfat apps using no$gba. The no$gba version can't seem to fopen() any files at all though.

I make the image from the C:\files folder which contains 'testdir', 'testdir2' and 'test.txt'. Then build using the modified makefile, all of this works fine. My test app currently tries to get the current working directory, check what files are in it, then attempts to load test.txt and output it's contents. This works fine on hardware but on no$gba it can't seem to open the file.

The output of my test app when using no$gba is:
Code:
Init fat: Success.
Getting CWD... fat:/
diropen() success.
 DIR: testdir
 DIR: testdir2
FILE: test.txt
Could not load file.


As you can see the files/folders seem to exist yet fopen() always fails. I've tried using 'fat:/test.txt', '/test.txt', './test.txt' etc. as the filename to fopen() none of them open.

Anyone have any idea whats going wrong? Thanks for reading.

Edit:
Solved just after posting. Removing the directory listing code allows me to open files. Dwedit's post about dirnext() corrupting the stack seems to be it.[/url]