Rewrite unrar parsing code
Review Request #124503 - Created July 28, 2015 and submitted
The parsing code of unrar was rewritten to hopefully improve readability. The output from unrar3 and 4 is identical and these will be referred to as unrar4. Unfortunately, it was not possible to reduce the length of the code. This is due to the output of unrar not being very parser-friendly and we want to support both unrar4 and 5, which have very different output. However, the new code should be easier to follow and hopefully more robust. Also, alot of comments have been inserted to ease maintenance of the code.
- readListLine() is now very short. It simply checks the version of unrar and calls unrar4 or 5 specific line-handling functions termed handleUnrar4Line() and handleUnrar5Line().
- When the line-handling functions have completed parsing all the details of an archive entry, they call an entry-handling function, either handleUnrar4Entry() or handleUnrar5Entry().
- The groundwork for handling comments in rar archives has also been laid, for now the comment is stored in a member QString variable (m_comment). The UI work for showing comments in archives is being done in RR124468).
In the process, two bugs were identified and fixed:
- The parsing of modification time for entries in unrar5 was broken.
- The target of symlinks was not being parsed in both unrar4 and 5, and hence not presented in Ark.
Tested different types of rar archives using both unrar 4 and 5:
- With encryption (both header/files and only files).
- With comment.
- With recovery record.
- With NTFS file streams stored (winrar feature).
- Multi-volume archives.
- Archive created using WinRAR on Windows 7.
- Some unrar versions output "(iconv)" after the version number (see the testReadArchiveWithSymlink.txt test), so a less specific RegExp was needed to parse the version string.
- When parsing the entry details of UNRAR4 output, we need to go back to header when finding horizontal line.
- The first line of UNRAR output is always empty so we ignore it and print an error when the second line doesn't match the version string RegExp.
Revision 2 (+306 -181)