📄 faq.txt
字号:
Q: I experience linking problems. What to do?
Q: When do I need to purchase the commercial license?
Q: When I open a multi-disk archive (Pkzip mode) and the last disk is not in
the drive, I receive the CZipException::cdirNotFound exception. How to detect
whether the last disk is in the drive?
Q: Of what size should be a single volume in a multi-disk archive created in
the TD span mode ?
Q: How can I detect the disk spanning mode of an archive?
Q: How to integrate the library with the sample application?
Q: Why the library doesn't want to extract archives (mostly old)?
Q: In CZipArchive::AddNewFile and CZipArchive::ExtractFile I want to use partial
path for the filename inside the archive.
Q: I want to create an archive that will be readable under Unix/Linux.
Q: How can I use UNC path with CZipArchive::ExtractFile function ?
Q: How to create a zip archive in memory and then write it to disk or
read the archive from the disk and extract from memory ?
Q: How can I extract or delete files that matches a specified wildcard pattern ?
Q: Why an exception is thrown when I call CZipArchive::CloseFile ?
*****************************************************************************
Q: I experience linking problems. What to do?
A:
If you get mostly LNK2005 :
If you changed the project configuration (e.g. from Release to Unicode Release), rebuild the projects.
If you are still getting link errors, make sure that the library and your program are both using single-threaded or both
multithreaded (or multithreaded DLL) run-time library. The option Project->Settings-> c/c++ ->Code Generation->Use run-time library
should be set to the same value in the ZipArchive library and the program
project options. Make sure that you link appropriate configurations (Release against Release, Debug against Debug...)
and that you're using MFC library in the same way (shared, static or not using) in those configurations.
If you get LNK1104 (e.g. cannot open file "mfc42u.lib")
You're trying to compile the Unicode version but you haven't installed the necessary libraries.
When installing Visual C++ Professional for example, you need to check the boxes "Static Libraries for Unicode" and
"Shared Libraries for Unicode". They are in "VC++ MFC and Template libraries\MS Foundation Class Libraries".
You don't need to reinstall the Visual Studio to add them.
Q: When do I need to purchase the commercial license?
A: The ZipArchive library is distributed under GNU GPL which implies that it can only be used
with software that is licensed under conditions compliant with the GPL. It means that
you need to provide a customer with the source code of your software that uses the library.
The commercial license removes this obligation. You can find out more at \ref s1.
Q: When I open a multi-disk archive (Pkzip mode) and the last disk is not in
the drive, I receive the CZipException::cdirNotFound exception. How to detect
whether the last disk is in the drive?
A: The last disk can not be detected before opening an archive. The only way to
prevent the program from failing when an incorrect disk is inserted is to
catch the CZipException::cdirNotFound exception while opening the archive and keep prompting the user to insert the last disk into the drive. Please see the sample application on how
it can be done in details.
Q: Of what size should be a single volume in a multi-disk archive created in
the TD span mode ?
A: The size of the volume may be from 1 byte to the maximum integer value, and the bigger - the
faster is creation and extraction (no file changes meantime), but the size
of the whole archive is the same. The optimal solution is to set it to about
the size of the diskette (a little less to be comfortable when there are bad sectors found on the disk) to allow the future conversion to PKZIP span mode.
Q: How can I detect the disk spanning mode of an archive?
A: You need to open the archive and the call CZipArchive::GetSpanMode. When opening the archive in tdSpan mode on a removable device, you should set iVolumeSize to a non-zero value while opening the archive (with CZipArchive::Open). There is no universal way to distinguish a PKSpan archive from a TDSpan archive on a removable device, because they have identical internal structure.
Q: How to integrate the library with the sample application?
A:The usual way is to put ZipArchive library at the same directory level what your
project is, and then use one of the integration methods .
Make a directory structure like this:
---
    |-ZipArc           // the application project
    |-ZipArchive   // the ZipArchive library
You can now follow the integration method 1 or 2 (the easier one).
Q: Why the library doesn't want to extract archives (mostly old)?
A: The common reason is that the data is compressed using imploded method (usually with old archivers).
The only methods supported by the zlib library are deflation which is the most commonly used by archivers and storing which is in fact not a compression method. You can use a compiled ZipArc application to find out what method the file was compressed with (View->File Info)
Q: In CZipArchive::AddNewFile and CZipArchive::ExtractFile I want to use partial
path for the filename inside the archive. For example:
When I compress some directory, like this:
c:\program files\example (full directory path: c:\program files\example\text\txt)
it comes with the whole path. I would like that the zip only get the EXAMPLE\text\txt path.
A: You can set bFullPath argument to false in these functions and set
the beginning part of the path that you commonly want to eliminate with
CZipArchive::SetRootPath function. In the example above you'd set it to
c:\program files\ (the path separator at the end is added automatically).
Q: I want to create an archive that will be readable under Unix/Linux.
A: Inside the archive there is an information stored about the system it was
created under. It helps converting the file attributes that are stored inside
the archive to file attributes that are used on the system on which the file is extracted.
Some Unix archivers cannot convert Windows attributes to Unix, so that it is needed
to create the archive with the Unix attributes already (and the internal info about the
system set to a Unix value). To achieve that, simply call CZipArchive::SetSystemCompatibility
with the argument set to ZipCompatibility::zcUnix after creating the archive.
Q: How can I use UNC path with CZipArchive::ExtractFile function ?
A: You need to replace \\ at the beginning of the UNC path with \\?\UNC\ .
Q: How to create a zip archive in memory and then write it to a disk or
read the archive from the disk and extract from memory ?
A: See (de)compression in/from memory
Q: How can I extract or delete files that matches a specified wildcard pattern ?
A: You need to build a CZipWordArray with CZipArchive::FindMatches and then:
- to delete: use the array as an argument to CZipArchive::DeleteFiles
- to extract: the array stores the indexes of the files to extract; you need to
enumerate the array and pass the indexes one-by-one to CZipArchive::ExtractFile function
Q: Why an exception is thrown when I call CZipArchive::CloseFile ?
A: If you haven't exctracted all of the file contents (e.g. only the beginning) or
you have encountered an exception during extraction, you need to call CZipArchive::CloseFile
with bAfterException parameter set to true or call CZipArchive::CloseFileWithNoUpdate instead.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -