Add embeddir

This commit is contained in:
2025-12-17 07:26:43 -06:00
parent 73bd9f94d3
commit 69b9343d71
9 changed files with 692 additions and 1 deletions

View File

@@ -0,0 +1,26 @@
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