Home | Forums | What's new | Resources | |
File.c |
vbt - Sep 10, 2003 |
RockinB | Sep 10, 2003 | |||
Thanks :bow VBT! I will try it out when I implement CD access in the next days. The Rockin'-B |
RockinB | Sep 17, 2003 | |||
Now that I'm dealing with CD access, there are some questions and correction: Filesize: Your GetFileSize() does not return the correct filesize. The file does not completely use all sectors(nsct) of size sctsize. That's why there is lastsize, which is the number of unused bytes in last sector. The correct filesize would then be: (sctsize*nsct) - (BYTES_PER_SECTOR - lastsize) with BYTES_PER_SECTOR usually being 2048. BTW: GFS_Load() does indeed return this correct filesize(as does GFS_Fread()), too. Then I really don't know why you try 10 times to load the file in LoadFile().... It could be better to keep the libwork and dirtable used when initializing global as it's done in SBL sample. I don't looked into the GFS sourcecode(except GFS_Load()), but possibly these are used later. I have currently problems with loading files. Don't know if GFS_Load() returns when all is finished - it does return the filesize - or if I have to wait till it's completed. But how should I do this? There is GFS_IsEof(), but you need a filehandle for this and GFS_Load() creates a local filehandle that I cannot use. Another problem that can occur in this context: Be carefull when setting MAX_OPEN to only 1. It's possible that GFS functions try to open a file, too. And then it fails and you don't know why... . OK, now this is part of the solution for my problem. |
RockinB | Sep 17, 2003 | |||||||
Back again! I found and read parts of the GFS manual. Indeed, GFS_Load() is a return on completion function. No need to pass trough the filesize, only the size of the buffer or GFS_BUFSIZ_INT. Now, after 10 CD-R's wasted, I provide some cool sourcecode for fast CD access. Do you remember how "The Need For Speed" eats your CD drive when loading games? The reason is because it does this: directory access -> file access -> directory access -> file access..... . The solution is to do all directory access in a batch and then accessing the files. So does my code. Some prenotes:
OK, and now the code:
Don't know if it might help you The Rockin'-B |
vbt | Sep 20, 2003 | ||||
Thanks for the right file size getting method. I don't remember why I did that. Maybe for a malloc before putting a file in memory. For SMS ROMs the file size was right, there was no unused bytes |
vbt | Dec 8, 2006 | ||||
[quote name='RockinB']Now that I'm dealing with CD access, there are some questions and correction: Filesize: Your GetFileSize() does not return the correct filesize. The file does not completely use all sectors(nsct) of size sctsize. That's why there is lastsize, which is the number of unused bytes in last sector. The correct filesize would then be: (sctsize*nsct) - (BYTES_PER_SECTOR - lastsize) with BYTES_PER_SECTOR usually being 2048. BTW: GFS_Load() does indeed return this correct filesize(as does GFS_Fread()), too. QUOTE] Quite old topic I finally fiexed the function and correct file size fonction looks like this :
Code:
Well in fact it's almost the same you wrote Rockin'-B, I tried to fix myself before posting here I still get another problem on file reading but it comes from something else. |