- [Prizm Poll] Rename Bfile_SeekFile_OS
- 31 Jul 2012 01:48:08 pm
- Last edited by AHelper on 31 Jul 2012 01:53:53 pm; edited 1 time in total
So, I wrote a large part of the file system tutorial on WikiPrizm. I am finally testing out the functions for the Bfile (MCS functions are easy and were tested before posting) and have found an issue. Here is my research on it:
Page 34 in the fx-9860G Libraries PDF says that Bfile_SeekFile "moves the file pointer of an open file." It has the definition of int Bfile_SeekFile(int HANDLE, int pos);
Running this test code, the expected data in the file should be "Hello World!", but instead reads "Hello People\0World!":
Code:
From testing, Bfile_SeekFile_OS ignores the second parameter and simply returns the current position in the file, just like ftell works:
Code:
I believe that Casio replaced SeekFile/fseek with TellFile/ftell. If you want to seek, you must use syscall 0x1DA9 according to Simon Lother (He also commented on this on an omnimaga post here: http://ourl.ca/820785 this was actually the first google result for bfile_seekfile_os)
Page 34 in the fx-9860G Libraries PDF says that Bfile_SeekFile "moves the file pointer of an open file." It has the definition of int Bfile_SeekFile(int HANDLE, int pos);
Running this test code, the expected data in the file should be "Hello World!", but instead reads "Hello People\0World!":
Code:
#define STR "Hello People"
// hFile is a valid handle to a file
Bfile_WriteFile_OS(hFile, STR, sizeof(STR)); // Succeeds, returns 13
Bfile_SeekFile_OS(hFile, 6); // Succeeds, returns 13
Bfile_WriteFile_OS(hFile, "World!", 7); // Succeeds, returns 7
From testing, Bfile_SeekFile_OS ignores the second parameter and simply returns the current position in the file, just like ftell works:
Code:
// hFile is a new handle
Bfile_SeekFile_OS(hFile, 0); // Returns 0
Bfile_WriteFile_OS(hFile, STR, sizeof(STR));
Bfile_SeekFile_OS(hFile, 0); // Returns 13
Bfile_WriteFile_OS(hFile, "World!", 7);
Bfile_SeekFile_OS(hFile, 0); // Returns 20
I believe that Casio replaced SeekFile/fseek with TellFile/ftell. If you want to seek, you must use syscall 0x1DA9 according to Simon Lother (He also commented on this on an omnimaga post here: http://ourl.ca/820785 this was actually the first google result for bfile_seekfile_os)