
On Feb 9, 2008, at 8:03 AM, Bertram Felgenhauer wrote:
Dave Bayer wrote:
What is the best way to embed an arbitrary file in a Haskell program?
I don't know the best way. I'd probably use FFI.
<snip>
The idea is then to use some existing tool that embeds binary data in C programs.
Since you're specifically interested in OS X, I'd follow this advice, and then look at /usr/include/mach-o/getsect.h. This header declares a function extern char *getsectdata( const char *segname, const char *sectname, unsigned long *size); which seems like it'll give you all of the data in one of the sections of the executable file for the currently running program. I haven't used it, though, so I'm not positive about how it works. I think it's then fairly straightforward to tell the linker to just include an arbitrary file into a section with a name of your choice. Aaron