Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement sparse files support #62

Merged
merged 8 commits into from
Apr 30, 2016

Conversation

tailhook
Copy link
Contributor

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.

pub struct GnuExtSparseHeader {
pub sparse: [GnuSparseHeader; 21],
pub isextended: [u8; 1],
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this also explicitly have the 7 bytes of padding to ensure that the header is 512 bytes in length?

@alexcrichton
Copy link
Owner

Awesome, thanks @tailhook! Could you also be sure to add enough tests to cover all the new code here as well?

@tailhook
Copy link
Contributor Author

I'm don't know how to make it simpler or how to write decoder in terms of io combinators. We can't do chain of the arbitrary number of readers not known at compile time. And even if we do, we can't borrow the reader twice.

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?

@alexcrichton alexcrichton merged commit ff91870 into alexcrichton:master Apr 30, 2016
@alexcrichton
Copy link
Owner

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?

@tailhook
Copy link
Contributor Author

Works fine for me. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants