5

I need to pass a binary resource that's compiled into my executable to some code that expects a file path, and then uses the C standard library FILE*-based API to access it.

Of course if I pass a path recognized by Qt, like :/something.smt - it won't work, because that's not visible directly to the C library.

Is there a way to bridge the two?

Kuba hasn't forgotten Monica
  • 95,931
  • 16
  • 151
  • 313
  • 1
    I don't think this is possible to do it directly. I believe you first need to extract the resource to a file. – drescherjm Jul 25 '19 at 21:07
  • Not without doing extra work, and not portably. But you can of course make this bridge, in an implementation-specific way for every C library: glibc, the one on Windows, and the one on macOS. That will cover all major platforms. So: you can do it, but you have to write some code to do it. – Kuba hasn't forgotten Monica Jul 26 '19 at 16:07
  • 2
    This is a decent question: it wasn't worded perfectly, but who would think that it was *unclear*? It's perfectly clear, and a common issue with various framework-specific virtual file systems. GTK users face the same issue, so doe those who use wxWindows, etc. – Kuba hasn't forgotten Monica Jul 26 '19 at 16:16
  • Under GLIBC, it's possible - see `fopencookie(3)`. But I'm not sure of the details. – o11c Jul 26 '19 at 19:19

0 Answers0