schovi / baked_file_system

Virtual File System for Crystal language. Embedding your assets into final binary.
MIT License
177 stars 17 forks source link

dot files support? #34

Open sam0x17 opened 5 years ago

sam0x17 commented 5 years ago

From what I can tell, this does not work with files begining with a dot, e.g. .gitignore. Is there a way to enable this?

straight-shoota commented 4 years ago

The globbing in bake_folder ignores hidden files. Adding an option to include them would be possible. As a workaround, you can simply add those files manually using bake_file.

MarcusE1W commented 2 years ago

It seems not only hidden files, but also hidden folders are affected. e.g. an installation in /home/user/.local/app did not work because of the dot folder.

straight-shoota commented 2 years ago

The fix should be simple. Dir.glob has a parameter match_hidden which allows to enable loading hidden files/folders. It's just a question whether this should be enabled by default and/or if it should be configurable. Maybe, for baked_file_system it actually makes most sense to always match hidden files, i.e. use match_hidden: true and it's not configurable.

straight-shoota commented 2 years ago

Oh, I just realized that it's not even Dir.glob at fault here. At least the issue with a root path containing a hidden folder name from https://github.com/mint-lang/mint/issues/544 is not caused by Dir.glob, but the following line where paths with hidden components are explicitly filtered out:

https://github.com/schovi/baked_file_system/blob/f086b45c52bac364e67b4b4c0b5698f2407215e2/src/loader/loader.cr#L23-L25

This obviously doesn't make any sense. It might just be a relic from older versions of Dir.glob which didn't support match_hidden. Even though I still don't think hidden files should be excluded. Using Dir.glob might not be the ideal solution here anyways. We really just need to walk the entire file tree starting at root_path in order to discover all file paths under it.