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

Not Working Support for Zip64 (file sizes > 4GB) #39

Open
mahendra-25 opened this issue May 2, 2020 · 1 comment · May be fixed by #51
Open

Not Working Support for Zip64 (file sizes > 4GB) #39

mahendra-25 opened this issue May 2, 2020 · 1 comment · May be fixed by #51
Labels

Comments

@mahendra-25
Copy link

mahendra-25 commented May 2, 2020

Your helper file is very much useful, I have used in my 3-5 projects but when I used in recent project where zipping was of more than 6gb folder, zip file was generating successfully but unzipping was making issue in checksum error.

After going through your code and comments I found that support for larger sizes file you have changed the WriteEndRecord parameter size but not changed in close function to send the value for the same so I have changed some little two things in two lines of your code.

Please change the data type in ### close() function at line### 334, 335 from uint to long as when there is bigger sizes files the stream position is at greater than the uint max size.

Please look the same and do changes for making this more awesome successful code.

    /// <summary>
    /// Updates central directory (if pertinent) and close the Zip storage
    /// </summary>
    /// <remarks>This is a required step, unless automatic dispose is used</remarks>
    public void Close()
    {
        if (this.Access != FileAccess.Read)
         {
            long centralOffset = this.ZipFileStream.Position;
            long centralSize = 0;

            if (this.CentralDirImage != null)
                this.ZipFileStream.Write(CentralDirImage, 0, CentralDirImage.Length);

            for (int i = 0; i < Files.Count; i++)
            {
                long pos = this.ZipFileStream.Position;
                this.WriteCentralDirRecord(Files[i]);
                centralSize += (uint)(this.ZipFileStream.Position - pos);
            }

            if (this.CentralDirImage != null)
                this.WriteEndRecord(centralSize + (uint)CentralDirImage.Length, centralOffset);
            else
                this.WriteEndRecord(centralSize, centralOffset);
        }

        if (this.ZipFileStream != null && !this.leaveOpen)
        {
            this.ZipFileStream.Flush();
            this.ZipFileStream.Dispose();
            this.ZipFileStream = null;
        }
    }

After changing code then to file extraction giving error of checksum please look in this issue.

@jaime-olivares
Copy link
Owner

Hi, I appreciate the analysis. Can you please create a pull request?

A9G-Data-Droid added a commit to A9G-Data-Droid/zipstorer that referenced this issue Oct 27, 2023
@A9G-Data-Droid A9G-Data-Droid linked a pull request Oct 27, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants