SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Set a internal file name of gzip file.

Last post 03-23-2017 1:44 PM by afonsoft. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 03-23-2017 1:44 PM

    • afonsoft
    • Not Ranked
    • Joined on 03-23-2017
    • BRAZIL
    • Posts 1

    Set a internal file name of gzip file.

    Hi, I need set a file name internal of gzip.

    I re-compiler ICSharpCode.SharpZipLib.csproj 

    I modifided a class GZipOutputStream

    Create a new method 

    private string _fname = "";

    /// <summary>

    /// Sets the name of internal file of gzip

    /// Create by Afonso Dutra

    /// </summary>

    /// <param name="name">name of internal file in de gzip</param>

    public void SetFileName(string name)

    {

    _fname = name;

    }

    And I modifided a exist method WriteHeader()

                             //AFONSO 

    byte[ fname = { 0 };

    if (!string.IsNullOrEmpty(_fname))

    {

    fname = Encoding.GetEncoding("ISO-8859-1").GetBytes(_fname);

    Array.Resize<byte>(ref fname, fname.Length + 1);

    fname[fname.Length - 1] = 0;

    }

    //END AFONSO

    And modifided de byte of Header

     

    byte[ gzipHeader = {

    // The two magic bytes

    (byte) (GZipConstants.GZIP_MAGIC >> 8),

    (byte) (GZipConstants.GZIP_MAGIC & 0xff),

    // The compression type

    (byte) Deflater.DEFLATED,

    // The flags (not set)

    (byte) (!string.IsNullOrEmpty(_fname) ?  GZipConstants.FNAME : 0), 

    // The modification time

    (byte) mod_time,

    (byte) (mod_time >> 8),

    (byte) (mod_time >> 16),

    (byte) (mod_time >> 24),

    // The extra flags

    0,

    // 255 The OS type (unknown)

    // 0 FAT filesystem (MS-DOS, OS/2, NT/Win32)

    (byte) 0 //255

    };

     

    For incluide a real file name in gzip, include is function after "baseOutputStream_.Write(gzipHeader, 0, gzipHeader.Length);"

                                //AFONSO

    if (!string.IsNullOrEmpty(_fname))

    baseOutputStream_.Write(fname, 0, fname.Length);

    //END AFONSO

     

    It´s possible incluide this code for future release?

     

    Thanks.

     

Page 1 of 1 (1 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.