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

CFSStream.Resize does not work #119

Closed
trash256 opened this issue Mar 2, 2024 · 1 comment
Closed

CFSStream.Resize does not work #119

trash256 opened this issue Mar 2, 2024 · 1 comment
Assignees
Labels

Comments

@trash256
Copy link

trash256 commented Mar 2, 2024

    public void Test()
    {
        var cf = new CompoundFile();
        const string DATA = "data";
        var st = cf.RootStorage.AddStream(DATA);
        const int size = 10;
        var data = Enumerable.Range(0, size).Select(v => (byte)v).ToArray();
        st.SetData(data);
        var ms = new MemoryStream();
        cf.Save(ms);
        cf.Close();

        ms.Position = 0;
        cf = new CompoundFile(ms, CFSUpdateMode.Update, CFSConfiguration.Default);
        st = cf.RootStorage.GetStream(DATA);
        st.Resize(5);   // <- can be any number smaller than the current size
        st.Write(new byte[] { 0 }, 0); // <- exception here!
        cf.Commit();
        cf.Close();
    }

Looks like truncating the stream does not work.

@ironfede ironfede self-assigned this Mar 2, 2024
@ironfede ironfede added the bug label Mar 2, 2024
@ironfede
Copy link
Owner

ironfede commented Mar 2, 2024

Thank you @trash256
This is a really high priority bug. I'm going to immediately relase a new nuget package.
Best Regards,
Federico

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

No branches or pull requests

2 participants