Get fils at compile-time

bauss (wtf happend to my name took some old cached title LOL??) via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 14 12:47:23 PST 2016


Is there a way to get all files in a folder at compile-time.

To be more specific I want to import the content of all files 
within a specific folder during compile-time. I know how to do it 
with a specific file using `import("filename")`, but what if I 
wanted to do it at compile-time for all files in a folder then 
loop through those files and handle their content.

To give an example.

Let's say I have a folder "styles" it has 3 files 
"global.stylesheet", "main.stylesheet", "shared.stylesheet".

Now I don't know about these file's names, so I can't just do it 
manually as they could be "foo", "bar" and "baz", just like 
they're "global", "main" and "shared".

There could even be more files, so eventually I'd have to load 
all files in somehow.

Ex.
enum string[] compileTimeFiles = loadFilesSomehowHere("styles");

Now if it was possible to just get the file names into 
`compileTimeFiles` then I could use "import" on each file name, 
but how would I even get them into that, if it's even possible?

Tbh. it's a very reasonable use-case if you ask me. Especially if 
it comes to dynamic generation of either code related to UI 
applications, web applications, websites etc.


More information about the Digitalmars-d-learn mailing list