opening a rar file by c

后端 未结 2 1724
礼貌的吻别
礼貌的吻别 2020-12-20 01:08

I have to write code in C to extract a password protected rar file in windows. I don\'t have any clue about how to do this. can anybody suggest me something or provide a sam

2条回答
  •  情话喂你
    2020-12-20 01:23

    Using unrar library - extracting files into a filestream buffer

    But if you're looking for a pure C solution, take a look at: http://www.unrarlib.org/

    Quote from their FAQ: The URARFileLib (short name for UniquE RAR File Library, also called unrarlib) is a free library for C programmers to access RAR archives.

    Another approach, which I just tested successfully, doesn't require the use of external libraries to decompress rar files. Use system() to invoke a command-line tool (such as unrar ) already installed on your system to do the job:

    system("unrar x -ppassword protected_file.rar /destination_directory");
    

    For instance, let's say the protected file was named file.rar, the password was 1234 and the destination directory was /home/user, you would call system() with the following parameters:

    system("unrar x -p1234 file.rar /home/user/");
    

提交回复
热议问题