Implement sparse files support#62
Conversation
| pub struct GnuExtSparseHeader { | ||
| pub sparse: [GnuSparseHeader; 21], | ||
| pub isextended: [u8; 1], | ||
| } |
There was a problem hiding this comment.
Could this also explicitly have the 7 bytes of padding to ensure that the header is 512 bytes in length?
|
Awesome, thanks @tailhook! Could you also be sure to add enough tests to cover all the new code here as well? |
|
I'm don't know how to make it simpler or how to write decoder in terms of I've fixed other issues and added tests. So given we now have the tests, can we merge it in, and refactor later if needed? |
|
Ok, I ended up rejiggering the code a bit and adding a few more pieces of functionality here and there, can you give it a whirl and see if it works for you? |
|
Works fine for me. Thanks! |
This adds a Read trait which emits all zeros on non-existing chunks of file.
Any ideas how to provide an interface where you could actually produce a sparse file on a filesystem? As far as I know there is no cross-platform way to create a sparse file, and so no way to do it with standard library. So maybe we should provide this functionality as iterator of blocks?
I've added super minimal example files, so I could test the library. Also I should add some tests for this pull request specifically.