schovi / baked_file_system

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

add method to access raw compressed data #32

Closed repomaa closed 5 years ago

repomaa commented 5 years ago

This is really useful for web servers when you don't want to decompress and then compress again with the HTTP::CompressHandler

straight-shoota commented 5 years ago

I'm not sure if duplicating the file entry is the best solution.

You can already access the raw data as #to_slice and write that to an IO (or wrap it in a memory IO).

repomaa commented 5 years ago

Hm yeah I know but i thought it'd be nicer to preserve the interface. Isn't duplicating the file just passing some references around?

repomaa commented 5 years ago

Oh.. no it's not. Slice is a struct of course. Ok this is a bad idea indeed.

straight-shoota commented 5 years ago

No, it's not duplicating the actual data. Slice is essentially just a pointer with size. That's not an issue.

But duplicating the file entry doesn't make much sense and can be surprising. It's cleaner to have just one instance per entry but having different means for accessing compressed or uncompressed data. IMHO that's already provided for.

Do you have a use case where #to_slice isn't enough?

repomaa commented 5 years ago

yeah to_slice should be fine..