Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to read the .gz files



  • hi ,some one please tell me how to open and read information in that file...please help me



  • Use 7zip manager or if u are on linux ,see tar man pages.

    How does the extraction of a file related to Qt ?



  • no i am working in unix...i want to read the zip file..



  • @$ gunzip file.gz
    $ gzip -d file.gz @

    Or may be ,you want to do some file operations with [[doc: QFile]]

    What exactly are you trying to do with the file ? {If its just a unix issue , or zip issue, this is not the ideal forum to ask}



  • [quote author="phani438" date="1324827256"]no i am working in unix...i want to read the zip file.. [/quote]

    Hello phani438,

    Can you explain your problem a bit better?
    Is this a Qt-related question?

    Bye!



  • [quote author="phani438" date="1324827256"]no i am working in unix...i want to read the zip file.. [/quote]

    • on the command line?
    • using QFile?
    • using standard C++ iostreams?
    • using standard C file handles?


  • i want to read the the zip file using Qfile...i have a file name mtbi.gz..i want to read the information using Qfile...



  • There is no Qt builtin way to read gzip compressed files with an QIODevice. You will have to resort either to call an external program or to incorporate "zlib":http://zlib.net/ into your program. For the former, you may call "gunizp -c" plus the path to your file via [[Doc:QProcess]] and read from the standard output of the process.



  • Way: locale unzipper in src/ directory. Build it. Now you can do it like that:
    @
    //.....
    shell = new QProcess(this);
    QStringList argv() << myfile.fileName();
    shell.start("./src/unzip",argv); // or in win32 - src/unzip.exe
    //.....
    @
    And you have to create some signal-slot connections. But at first read about QProcess and gzip



  • This is a FAQ. There is an entry on it "here":http://developer.qt.nokia.com/faq/answer/how_to_compress_data_with_qt .


Log in to reply