Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Samples

loadfs sample

A community discussion post from the original code:zIRON forum.

Colin admin
Posts
928
Threads
49
Location
Bulgaria

loadfs sample

loadfs is a recent addition to the Ziron compiler, it allows to load a file into a string, which can be used for numerous things, here i have quickly put together a tiny sample showing it in use...

in my case i have an image in the same directory as the source named leia.jpg you can change this of course... the exe when compiled will embed the image and when the exe is ran it will write test.jpg, this file is obviously the file you embedded, in my case leia.jpg

program WIN32GUI 'Sample';

//include file i/o macro inc file.
#include 'fileio.zir';

//create our file handle variable and create an empty file
DWord hFile = filecreate('.\\test.jpg');
//notice the loadfs which embeds the image at compile time
//write the embedded image at runtime, length is in bytes
DWord bytes = filewrite(hFile, loadfs('.\\leia.jpg'), 186347);
//close the file handle
fileclose(hFile);

//exit the application
ExitProcess(0);

this sample can be compiled with compiler version 1.1.11.1