vendredi 20 août 2021

How do I check if a file pointer is valid?

I am using fseek and fread on a FILE * like this:

void CAudioDataItem::finalizeItem_ReadEncodedBytesWithoutDecoding(FILE* uFile, CLog* uLog, double& uTimeReadEncodedBytes)
{
    //t.start();
    fseek(uFile, iFirstByteToRead, SEEK_SET);
    fread(&m_EncodedBytes[0], sizeof(unsigned char), m_lLenEncodedBytes, uFile);
    //t.stop();

However, it doesn't work, the bytes are all 0.

I suspect that somewhere in my app, the FILE pointer gets invalid or something else becomes wrong with this pointer.

How could I check if this file handle is still valid and "usable"?

Here is a screenshot:

enter image description here


Here is a screenshot of a situation where it still works. As one can see, the _Placeholder is different. What does this _Placeholder mean?

enter image description here

Aucun commentaire:

Enregistrer un commentaire