Open
Description
The Finder Opta device contains a 2Mbyte QSPI flash.
When calling UFile::available()
to get the file size (file position still at 0 after opening), I would expect the file size. But I get almost flash size.
- Firstly I have seen that when you call
ftell()
you use integer type instead of the required
typelong
. On different platforms,int
can use from one to 4 bytes. UFile::available()
return type isuint32_t
, but typicallysize_t
should be used, as this
is semantically the same as file position or number of bytes written/read.- In this function there are no check if the call to
ftell()
was successful. The returned data are just used. but those could be wrong if seeking failed. - Using
ftell(,,SEEK_END)
is not implemented on every platform.
please see https://en.cppreference.com/w/c/io/fseek (right at the beginning).
For this Finder Opta device (supported by Arduino) the current position returned after
seeking to end and callingtell()
, returns 1966048 bytes. Same file on USB returns the correct size (e.g. 128780) - Also UFile should support
ftell
andfflush
as API (see end of page under section "Notes").
If you like you may create several issues for this one and separate it. I just wanted to tell you my findings.