including arbitrary files into the binary

Jarrett Billingsley kb3ctd2 at yahoo.com
Sat Sep 8 07:48:35 PDT 2007


"mandel" <mandel at foobar.com> wrote in message 
news:fbuc6n$e8h$1 at 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. 





More information about the Digitalmars-d mailing list