fseek() doesn't work any more as it should

Support for the GBA/DS/Gamecube/Wii media card library
Post Reply
ain faren lasen
Posts: 8
Joined: Sun Dec 28, 2008 3:07 pm

fseek() doesn't work any more as it should

Post by ain faren lasen » Sun Mar 01, 2009 8:24 pm

Hi,
I just updated devkitpro to the new version, and now my small homebrew project for the NDS doesn't work anymore on the No$GBA. To be precise, the line

Code: Select all

fseek (f , 0 , SEEK_END);
returns garbage now - it returns a size in the range of ~2GB.
But it fails only on the No$GBA! (I use the same steps as described here.) On the NDS, my project does fine. I tried to recompile the fcsr.dldi, but that didn't help either.
Regards,
ain

NightFox
Posts: 7
Joined: Fri Mar 20, 2009 1:51 am

Re: fseek() doesn't work any more as it should

Post by NightFox » Mon Mar 23, 2009 10:22 pm

i has the same issue when using ftell(). Tested both on ideas and no$gba. On real hard works nice...
Anyone knows how to fix it ?

ain faren lasen
Posts: 8
Joined: Sun Dec 28, 2008 3:07 pm

Re: fseek() doesn't work any more as it should

Post by ain faren lasen » Tue Mar 24, 2009 2:23 pm

I got a solution for my problem, don't know if it helps in your case.

I now include filesystem.h and write the following:

Code: Select all

if(!nitroFSInit())
{
   if(!fatInitDefault())
   return false;
}
... instead of initialising libfat only. This way it works on No$GBA and on hardware.

HTH,
ain

NightFox
Posts: 7
Joined: Fri Mar 20, 2009 1:51 am

Re: fseek() doesn't work any more as it should

Post by NightFox » Tue Mar 24, 2009 4:47 pm

Hi!
Including #include <filesystem.h> then adding you code i just get a erro compiling

1>main.o: In function `main':
1>c:/NDS/projects/nflib/nflib/source/main.cpp(29): undefined reference to `nitroFSInit()'
1>collect2: ld returned 1 exit status
1>make[1]: *** [/c/NDS/projects/nflib/nflib/nflib.elf] Error 1
1>make: *** [build] Error 2

Im using makefile from FAT example of R25 and Visual C++ 2005 Express to compile.

I fixed (for now) by using old version of fat.h & fat.o, but i get some warning at compile, but it works at least on no$gba.
Hope this will be fixed, it's realy usefull can test code on the emulator.

ain faren lasen
Posts: 8
Joined: Sun Dec 28, 2008 3:07 pm

Re: fseek() doesn't work any more as it should

Post by ain faren lasen » Wed Mar 25, 2009 10:03 pm

NightFox wrote:Including #include <filesystem.h> then adding you code i just get a erro compiling
You get a linker error, not compiler error. :) You need to add the filesystem lib to your make file, just set "-lfilesystem" before "-lfat".

HTH,
ain

NightFox
Posts: 7
Joined: Fri Mar 20, 2009 1:51 am

Re: fseek() doesn't work any more as it should

Post by NightFox » Wed Mar 25, 2009 11:10 pm

Ok
Still not working, ftell() still returning a size of 2112157696 bytes (when real size of file is 24576 bytes) running it on no$gba or ideas.
by the way, to can compile with filesystem.h, i detected a small bug on filesystem.h to can compile right with Visual C++

The filesystem.h that comes with R25 is

Code: Select all

#ifndef _filesystem_h_

bool nitroFSInit();

#endif // _filesystem_h_
And to can compile under C++ should be

Code: Select all

#ifndef _filesystem_h_

#ifdef __cplusplus
extern "C" {
#endif

bool nitroFSInit();

#ifdef __cplusplus
}
#endif

#endif // _filesystem_h_
By the way, it still not working on emu ^^

Regards

Fox

ain faren lasen
Posts: 8
Joined: Sun Dec 28, 2008 3:07 pm

Re: fseek() doesn't work any more as it should

Post by ain faren lasen » Fri Mar 27, 2009 1:19 pm

Works for me. :/

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests