- Ensure the seek position is within the actual file size.
- Use 64-bit integers (`int64`) for file positions to avoid floating-point inaccuracies.
- Implement a wrapper function for the seek operation that checks the validity of the seek position before attempting to seek.
- If necessary, contact the vendor for support or consult the documentation for proprietary functions like `DsFileReader`.
DsFileReader Seek issue with values >= (2^63 - 2^10)
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Smattering_Applause
le 28 Fév 2022
Commenté : Smattering_Applause
le 5 Fév 2024
I am using DsFileReader to read .mf4 files (ASAM MDF spec files).
One of my files has some corrupted values that return locations well outside the range. Strangely, when calling seek(), DSFileReader can handle them until the value exceeds (2^63-2^10-1). For reference, this file claimes the size is 141397456 (under 2^27). If I try to seek to (2^63 - 2^10) then it will fail.
When the error occurs, I get ByteStreamSeekFailure: iostream stream error. This error is not caught by any Try/Catch, and doesn't have a code, so tracking down the issue is much tougher. I have managed to track it to the call of fr.Stream.seek(bytes, originNum); within the seekWithParsedInputs() function, and I can see the Stream is created as a matlab.io.internal.vfs.stream object, but those files don't appear browsable.
While I know my file is corrupted, I wanted to understand when to expect this non-trackable error so I can make sure any fix for where I am seeking will work and send a proper error before this non-sourced error. (also it's odd that 2^64-2^10 is the magic error threshold, I think it has to do with the biggest integer below 64 bits that Double can represent)
0 commentaires
Réponse acceptée
Pratyush
le 5 Fév 2024
Hi,
The issue you're facing with "DsFileReader" when seeking to a position "(2^63 - 2^10)" in a .mf4 file is likely due to limitations in MATLAB's floating-point representation and the underlying stream's capability. MATLAB can exactly represent integers up to "2^53 - 1" with double-precision floating-point numbers, and seeking beyond the limits of the stream can cause a "ByteStreamSeekFailure" error, which is not catchable with a try/catch block.
To handle this, you should:
Hope this helps.
1 commentaire
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Import and Export dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!