Files
crosslang-tutorials/8 Embeddir/HOW IT WORKS.txt
2025-12-17 07:26:43 -06:00

26 lines
814 B
Plaintext

The program
const mydir = embeddir("mydir");
Console.WriteLine(FS.ReadAllText(mydir,"/cross.json")); //prints the file contents of the embedded file from res/mydir/cross.json
The res dir files
res/mydir/cross.json
res/mydir/src/main.tcross
res/mydir/src/other.tcross
res/mydir/res/icon.png
the dictionary generated by the compiler
{
.["cross.json"] = () => embedstrm("mydir/cross.json"),
.["src"] = {
.["main.tcross"] = () => embedstrm("mydir/src/main.tcross"),
.["other.tcross"] = () => embedstrm("mydir/src/other.tcross")
},
.["res"] = {
.["icon.png"] = ()=> embedstrm("mydir/res/icon.png")
}
}
the instruction embeddir is right after the dictionary generated by compiler
this instruction pops the dictionary and returns a wrapper filesystem called EmbedDirectory