mirror of
https://onedev.site.tesses.net/crosslang/crosslang-tutorials
synced 2026-02-08 17:15:46 +00:00
Add embeddir
This commit is contained in:
26
8 Embeddir/HOW IT WORKS.txt
Normal file
26
8 Embeddir/HOW IT WORKS.txt
Normal 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
|
||||
Reference in New Issue
Block a user