I don’t seem to have problems detecting them in rojff. Perhaps you could look there for some inspiration?
Specifically, the file reading logic is here.