tilpner / includedir

Include a whole directory tree at compile time
BSD 3-Clause "New" or "Revised" License
81 stars 7 forks source link

Tree API? #2

Open tilpner opened 8 years ago

tilpner commented 8 years ago

I didn't use this with a large amount of files or deep file structures yet, but while a phf map may be fast, it breaks down as soon as the included directories become deeper and more complex.

Would a filesystem-ish tree API be a better fit here? One could imitate the std::fs API without writability, to allow for proper path manipulation, directory listing, tree walking, etc.

Opinions? @emk

emk commented 8 years ago

A filesystem-like API would certainly be nice for some use-cases.

My use case is a simple, Rails-style source code template engine for generating new projects and for adding new components to existing projects. The input templates are here.

As you can see, I basically just open templates/new (or templates/_overrides/_default), and then selectively walkdir everything below that point, filtering out anything which begins with an underscore _.

So if you had a filesystem API, I could certainly use it, but it's not absolutely critical in this particular case, because falling back to brute force still has acceptable performance. But for a case like game assets, where there are potentially many more files, then an fs-like API could certainly be useful.

But in any case, the critical operation in my case is walkdir with filtering. Thank you for asking!