digitalmars.D - including arbitrary files into the binary
- mandel <mandel foobar.com> Sep 08 2007
- "Jarrett Billingsley" <kb3ctd2 yahoo.com> Sep 08 2007
- Walter Bright <newshound1 digitalmars.com> Sep 08 2007
Hi,
I like to include arbitrary files into the D binary.
writefln(import("data.txt"))
let you include a single file as char[], but that is not sufficient.
I like to include all files from some subdirectories ( ~200 small files).
Ideally I like to create an AA with a path/filename as key
and the file content as value.
They are two problems I see with that:
1. manually writing an import for every file.
2. import doesn't seem to allow you to import with path like
import("mydir/data.txt"),
all files must be in the directory defined by the compiler option -J
Is there a solution to this problem?
Sep 08 2007
"mandel" <mandel foobar.com> wrote in message news:fbuc6n$e8h$1 digitalmars.com...Hi, I like to include arbitrary files into the D binary. writefln(import("data.txt")) let you include a single file as char[], but that is not sufficient. I like to include all files from some subdirectories ( ~200 small files). Ideally I like to create an AA with a path/filename as key and the file content as value. They are two problems I see with that: 1. manually writing an import for every file. 2. import doesn't seem to allow you to import with path like import("mydir/data.txt"), all files must be in the directory defined by the compiler option -J Is there a solution to this problem?
You could write a D program that does all this machination for you as a build step or so. It could copy all the files to a directory, come up with an AA, write out a .d file with the AA declaration and the imports, and then compile that into an object, which you then link into your program.
Sep 08 2007
Jarrett Billingsley wrote:You could write a D program that does all this machination for you as a build step or so. It could copy all the files to a directory, come up with an AA, write out a .d file with the AA declaration and the imports, and then compile that into an object, which you then link into your program.
For the AA declaration you can use hex string literals for the binary data: x"00 0A FD EE" etc. They're easy for a simple D program to generate.
Sep 08 2007








Walter Bright <newshound1 digitalmars.com>