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

Ability to modify content in a stream #7

Closed
cgilling opened this issue May 18, 2016 · 6 comments
Closed

Ability to modify content in a stream #7

cgilling opened this issue May 18, 2016 · 6 comments

Comments

@cgilling
Copy link

I'm in the middle of trying to transition some code that I have written in C/C++ over to go and one of the pieces that I have is something that will go into the file and turn off macros in .doc files so as to make them safer to process in ms word. In order to do this, I merely go into the doc file and flip the length of the micro section to be 0 so that word no longer picks up the macros.

To enable this in go I would need the ability to be able to modify streams. I'm wondering if you would be open to the idea of having File object allow overwriting (not appending as that sounds much more complicated).

@richardlehane
Copy link
Owner

Hi cgilling
I've just had a quick go at adding the io.Seeker and io.Writer interfaces to File objects.
This should allow you to seek within a File and change bytes.
Make sure your underlying source is an io.WriterAt and has write permissions if a file.

Current implementation is quick and nasty and the test function (https://github.com/richardlehane/mscfb/blob/master/mscfb_test.go#L146) isn't at all comprehensive. So please consider this experimental feature for now.

Will be interested to hear how you get on with it.

cheers
Richard

@richardlehane
Copy link
Owner

some tests now failing, this needs a bit more work, shouldn't take long

@richardlehane richardlehane reopened this May 19, 2016
@richardlehane
Copy link
Owner

basic tests, now passing. Added ReadAt() and WriteAt() methods too. See doco at https://godoc.org/github.com/richardlehane/mscfb for usage. Think this is ready to go now.

@cgilling
Copy link
Author

sweet thanks, I'll give it a spin soon

@cgilling
Copy link
Author

cgilling commented May 23, 2016

Just a quick update, works great, I was able to implement what I wanted and sent 100,000 random documents through it (of various filetypes include non mscfb filetypes) and no crashing.

Thanks again for the quick turnaround on the request

@richardlehane
Copy link
Owner

Glad to hear, thx for the request

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

No branches or pull requests

2 participants