Page 1 of 1

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

Posted: Sun Mar 01, 2009 8:24 pm
by ain faren lasen
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

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

Posted: Mon Mar 23, 2009 10:22 pm
by NightFox
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 ?

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

Posted: Tue Mar 24, 2009 2:23 pm
by ain faren lasen
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

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

Posted: Tue Mar 24, 2009 4:47 pm
by NightFox
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.

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

Posted: Wed Mar 25, 2009 10:03 pm
by ain faren lasen
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

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

Posted: Wed Mar 25, 2009 11:10 pm
by NightFox
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

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

Posted: Fri Mar 27, 2009 1:19 pm
by ain faren lasen
Works for me. :/