How to embed data within an executable?
Orvid King
blah38621 at gmail.com
Sun Feb 2 09:24:54 PST 2014
On Sun, 02 Feb 2014 10:52:37 -0600, bearophile <bearophileHUGS at lycos.com>
wrote:
> Gary Willoughby:
>
>> I'm using DMD to create an executable and wondered what is the best way
>> to embed data into it.
>>
>> For example, i want to embed base64 image data in the executable then
>> access it during runtime. Is this possible? if so how?
>
> There are various ways to do it. If your data is not too much, one way
> is to use a "hex string". You can also use mixin(import("...")).
>
> Bye,
> bearophile
What's the purpose of the mixin portion of that? The documentation for
file imports say that `import("...")` produces a string, so `__gshared
immutable myFile = Base64.encode(import("myFile"));` should work
perfectly, provided "myFile" is in a path passed to dmd with the -j switch.
More information about the Digitalmars-d-learn
mailing list