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

Set and Get a file name internal gzip #176

Closed
wants to merge 1 commit into from
Closed

Set and Get a file name internal gzip #176

wants to merge 1 commit into from

Conversation

afonsoft
Copy link

Steps to reproduce

I need to compress a file in a Gzip, but when I rename the gzip file, it is also renamed the internal file.

Expected behavior

The internal gzip file is always renamed

Actual behavior

Modify the head of the gzip to enter the real name of the internal file

#175
Change this file ICSharpCode.SharpZipLib.GZip.GZipOutputStream.cs

@afonsoft
Copy link
Author

Nice

@afonsoft
Copy link
Author

Hi, have a prevision about this request?

@sgrips
Copy link

sgrips commented Jan 15, 2018

Hi,
When will be your modify (@afonsoft ) go to in release ?? In the NuGet version there is no this change :(

best regards

@piksel piksel self-assigned this May 12, 2018
@piksel piksel added the NeedMIT label May 12, 2018
Copy link
Member

@piksel piksel left a comment

Choose a reason for hiding this comment

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

Some changes needs to be done before this can be merged.

Also, you need to add the contribution paragraph to your PR message:
I certify that I own, and have sufficient rights to contribute, all source code and related material intended to be compiled or integrated with the source code for the SharpZipLib open source product (the "Contribution"). My Contribution is licensed under the MIT License.

@@ -104,6 +105,27 @@ public int GetLevel()
{
return deflater_.GetLevel();
}

//AFONSO DUTRA
Copy link
Member

Choose a reason for hiding this comment

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

Please don't put your attribution in comments like this.
Git keeps track of who made which changes.

/// Set a file name internal gzip
/// </summary>
/// <param name="filename">name of file zipped</param>
public void SetFileName(string filename)
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be a Property

@@ -196,7 +218,8 @@ void WriteHeader()
(byte) Deflater.DEFLATED,

// The flags (not set)
0,
//0,
(byte) (!string.IsNullOrEmpty(_fileName) ? GZipConstants.FNAME : 0), //AFONSO: File Name
Copy link
Member

Choose a reason for hiding this comment

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

The flags should be put in an enum that can be cast into a byte here, also remove the commented 0

var fileNameBytes = System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes(_fileName);
Array.Resize<byte>(ref fileNameBytes, fileNameBytes.Length + 1);
fileNameBytes[fileNameBytes.Length - 1] = 0;
baseOutputStream_.Write(fileNameBytes, 0, fileNameBytes.Length);
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps nitpick, but you could simply call Write a second time with just a 0-byte instead of resizing the array.

@sgrips
Copy link

sgrips commented Nov 20, 2018

Sorry but after update package NUGET SharpZipLib.0.86.0 to SharpZipLib.1.0.0 was been removed SetFileName Method in GZipOutputStream Class, WHY ? @piksel

@piksel
Copy link
Member

piksel commented Jun 15, 2019

@sgrips This functionality was never merged since author did not add the contributor paragraph, nor make the necessary changes.

@afonsoft afonsoft closed this Jul 26, 2019
@afonsoft
Copy link
Author

old version

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 this pull request may close these issues.

None yet

3 participants