Thanks again,

Unfortunately I need to find a portable multiplatform solution. I know have a 
"builder" file that will output the contents of the binary to a txt file, which 
is then read in using the `emit` approach. Unfortunately, though, `escape` does 
not seem to be the right function here, as it triplicates the size of the txt 
file, and it does not represent the file as `staticRead` does (by looking at 
the resulting C code). Is there a way to get the exact C representation that 
`staticRead` does as a string?

`builder.nim`
    
    
    import strutils
    
    let omni_tar = readFile("build/omni.tar.xz")
    writeFile("omni_tar.txt", omni_tar.escape("", ""))
    writeFile("omni_tar_len.txt", $omni_tar.len)
    
    
    Run

`reader.nim`
    
    
    {.emit:"""STRING_LITERAL(omni_tar_xz, "omni.tar.xz", 11);""".}
    {.emit:["""__attribute__((section(".omni_tar,\"aw\""))) 
string_literal(omni_tar,"""", staticread("omni_tar.txt").static, "\",", 
staticread("omni_tar_len.txt").static, ");"].}
    
    
    Run

Reply via email to