digitalmars.D - Resource File Accessing
- Plumm (3/3) Dec 27 2008 Hi :
- Jarrett Billingsley (8/11) Dec 27 2008 Easier even than that. The import() expression allows you to include
- Nick Sabalausky (4/23) Dec 27 2008 That would have been great to have back when I was doing GBA homebrew. W...
- Daniel Keep (12/29) Dec 28 2008 That's pretty much the cleanest solution there is.
- Andrei Alexandrescu (3/30) Dec 28 2008 Please allow me to grab credit for that one :o).
- Lionello Lunesu (4/11) Dec 28 2008 But shouldn't it return a void[] or byte[] by default? If it's known to ...
- Bill Baxter (5/17) Dec 28 2008 Yes.
- Plummtw (1/11) Dec 28 2008 Oh...Thanks for the answer...
Hi : I would like to include a binary file about 64K in my exe to make it a single executable file, any tip how to make the resouce file? compile the resource file, and how to access it in the D program? And since I use DWT, I already linked my program with a dwt.res got from Frank, should I ask Frank for the rc file so that I can append the binary file into the rc file? Thanks
Dec 27 2008
On Sat, Dec 27, 2008 at 11:33 PM, Plumm <sailormoontw gmail.com> wrote:Hi : I would like to include a binary file about 64K in my exe to make it a single executable file, any tip how to make the resouce file? compile the resource file, and how to access it in the D program? And since I use DWT, I already linked my program with a dwt.res got from Frank, should I ask Frank for the rc file so that I can append the binary file into the rc file? ThanksEasier even than that. The import() expression allows you to include arbitrary data in your app. const data = cast(byte[])import("filename.dat"); All you have to do is pass the -J flag to DMD to indicate the path where filename.dat lives. import() returns a string (a char[]) but you can cast it to whatever type you want, like I've casted to byte[] here. :)
Dec 27 2008
"Jarrett Billingsley" <jarrett.billingsley gmail.com> wrote in message news:mailman.272.1230439483.22690.digitalmars-d puremagic.com...On Sat, Dec 27, 2008 at 11:33 PM, Plumm <sailormoontw gmail.com> wrote:That would have been great to have back when I was doing GBA homebrew. We used to use separate util apps to convert data files into ".h" includes.Hi : I would like to include a binary file about 64K in my exe to make it a single executable file, any tip how to make the resouce file? compile the resource file, and how to access it in the D program? And since I use DWT, I already linked my program with a dwt.res got from Frank, should I ask Frank for the rc file so that I can append the binary file into the rc file? ThanksEasier even than that. The import() expression allows you to include arbitrary data in your app. const data = cast(byte[])import("filename.dat"); All you have to do is pass the -J flag to DMD to indicate the path where filename.dat lives. import() returns a string (a char[]) but you can cast it to whatever type you want, like I've casted to byte[] here. :)
Dec 27 2008
Jarrett Billingsley wrote:On Sat, Dec 27, 2008 at 11:33 PM, Plumm <sailormoontw gmail.com> wrote:That's pretty much the cleanest solution there is. Another trick I've used in the past is to simply append the extra data to the executable. At least under Windows, this doesn't affect the program at all. If the binary data isn't a fixed size, you can also append a small stub that specifies how big the file is. Then, the file's contents start at (eof - stub_size - data_size) within the program's own executable. Really, the only advantage to this over using import() is that you can change the data post-compilation (I've used this trick for a script interpreter which "compiled" scripts into a standalone executable.) -- DanielHi : I would like to include a binary file about 64K in my exe to make it a single executable file, any tip how to make the resouce file? compile the resource file, and how to access it in the D program? And since I use DWT, I already linked my program with a dwt.res got from Frank, should I ask Frank for the rc file so that I can append the binary file into the rc file? ThanksEasier even than that. The import() expression allows you to include arbitrary data in your app. const data = cast(byte[])import("filename.dat"); All you have to do is pass the -J flag to DMD to indicate the path where filename.dat lives. import() returns a string (a char[]) but you can cast it to whatever type you want, like I've casted to byte[] here. :)
Dec 28 2008
Daniel Keep wrote:Jarrett Billingsley wrote:Please allow me to grab credit for that one :o). AndreiOn Sat, Dec 27, 2008 at 11:33 PM, Plumm <sailormoontw gmail.com> wrote:That's pretty much the cleanest solution there is.Hi : I would like to include a binary file about 64K in my exe to make it a single executable file, any tip how to make the resouce file? compile the resource file, and how to access it in the D program? And since I use DWT, I already linked my program with a dwt.res got from Frank, should I ask Frank for the rc file so that I can append the binary file into the rc file? ThanksEasier even than that. The import() expression allows you to include arbitrary data in your app. const data = cast(byte[])import("filename.dat"); All you have to do is pass the -J flag to DMD to indicate the path where filename.dat lives. import() returns a string (a char[]) but you can cast it to whatever type you want, like I've casted to byte[] here. :)
Dec 28 2008
--snip--But shouldn't it return a void[] or byte[] by default? If it's known to be UTF8, then it can be cast to char[] explicitely. L.Please allow me to grab credit for that one :o).All you have to do is pass the -J flag to DMD to indicate the path where filename.dat lives. import() returns a string (a char[]) but you can cast it to whatever type you want, like I've casted to byte[] here. :)That's pretty much the cleanest solution there is.
Dec 28 2008
On Mon, Dec 29, 2008 at 1:42 PM, Lionello Lunesu <lionello lunesu.remove.com> wrote:--snip--Yes. http://d.puremagic.com/issues/show_bug.cgi?id=1985 --bbBut shouldn't it return a void[] or byte[] by default? If it's known to be UTF8, then it can be cast to char[] explicitely.Please allow me to grab credit for that one :o).All you have to do is pass the -J flag to DMD to indicate the path where filename.dat lives. import() returns a string (a char[]) but you can cast it to whatever type you want, like I've casted to byte[] here. :)That's pretty much the cleanest solution there is.
Dec 28 2008
Jarrett Billingsley Wrote: Easier even than that. The import() expression allows you to include arbitrary data in your app. const data = cast(byte[])import("filename.dat"); All you have to do is pass the -J flag to DMD to indicate the path where filename.dat lives. import() returns a string (a char[]) but you can cast it to whatever type you want, like I've casted to byte[] here. :)Oh...Thanks for the answer...
Dec 28 2008