mirror of
https://onedev.site.tesses.net/crosslang/crosslang-tutorials
synced 2026-02-08 09:05:47 +00:00
26 lines
814 B
Plaintext
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 |