-
Notifications
You must be signed in to change notification settings - Fork 968
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
Conversation
Nice |
Hi, have a prevision about this request? |
Hi, best regards |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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.
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 |
@sgrips This functionality was never merged since author did not add the contributor paragraph, nor make the necessary changes. |
old version |
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