-
The files required for all the library versions are located in the program root directory. You also need to copy additional files to the library root directory from the two more subfolders. Depending on the configuration these files are located in:
\Windows and \mfc
You can just execute _copy from Win-MFC.bat batch file.
\Windows and \stl
You can just execute _copy from Win-STL.bat batch file.
\Linux and \stl
You can just execute _copy_from_Linux.sh script file (don't forget to set executable rights before e.g. with the command: chmod +x _copy_from_Linux.sh ).
- Note:
- If you are compiling under FreeBSD, Mac, you need to comment include of
sys/vfs.h
in ZipPlatform.cpp and uncomment includes of sys/param.h
and sys/mount.h
.
On some systems (m68k and the SPARC) when you want to compile the library for dynamic linking you need to modify makefile files (for the zlib and ZipArchive) so that CFLAGS
have -fPIC
option set.
To add ZipArchive library functionality into your project you need to link the library to the project. You can do this at least in two ways (in both cases you need to include ZipArchive.h header in your sources).
Add ZipArchive.lib with the proper path e.g. ..\ZipArchive\debug\ZipArchive.lib to
- VS 6.0
- Project Settings->Link->Input->Object/library modules
- VS 2003 and VS 2005
- Project Properties->Linker->Input->Additional Dependencies
and add ZipArchive library directory to the preprocessor searches
- VS 6.0
- Project Settings -> C++ -> Preprocessor -> Additional include directories
- VS 2003 and VS 2005
- Project Properties -> C/C++ -> General -> Additional include directories
- VS 6.0
- Insert Zip project into workspace and set project dependencies: your project dependent on ZipArchive project ( Project -> Dependencies ). On the dialog that will appear you select your project name from the combo box and check the box next to ZipArchive project name.
- VS 2003 and VS 2005
- Set your project to reference the ZipArchive project (on the Solutions Explorer).
When you use this method, you link configurations in your project with configurations in the ZipArchive project that have the same name in both projects. So if you need to use for example "Debug" configuration from ZipArchive project, you need to create one with the same name in your application project and make sure that your project uses MFC library and run-time library in same way.
- VS 6.0
- Project->Settings->General->Microsoft Fundation Classes and Project->Settings-> C/C++ ->Code Generation->Use run-time library
- VS 2003 and VS 2005
- Project Properties->General->Use of MFC and Project Properties-> C/C++ ->Code Generation->Runtime library
When you're using the DLL version of the ZipArchive library, you need to define in your program ZIP_HAS_DLL e.g. in: - VS 6.0
- Project Settings -> C++ -> Preprocessor -> Preprocessor definitions
- VS 2003 and VS 2005
- Project Properties -> C/C++ -> Preprocessor -> Preprocessor definitions
- Only for VS 6.0
- Apart from integrating the ZipArchive library with your program (use one of the methods above), you also need to take into account zlib.lib file (use zlib/zlib.dsw to create it and add to preprocessor includes) or zlib/zlib.dsw project (insert into workspace and set ZipArchive project dependent on it).
Files ZipArchive.dll and zlib.dll (the last one only when you were compiling using Visual Studio 6.0 projects) must be available for the program when running (e.g. in the program's directory).
You can read about linking problems in the FAQ.
Project files for Borland C++ 5.0 are available. They were created using Visual C++ Project Conversion Utility (VCTOBPR.EXE). You can start this tool with the command Tools->Visual C++ Project Conversion Utility .
- Note:
- Be sure to create Release subfolder before compiling one of these projects, otherwise you'll get a write error.
In case the projects provided don't work for you, you can create your own. You need to copy to the root directory appropriate files for MFC or STL versions. You may use the Borland project conversion utility.
There are also makefiles available which should work with other versions of Borland.
There is a Borland C++ project available for the sample application ZipArc
.
To compile it you need compiled MFC version of ZipArchive library.
- Note:
- Be sure to create Release subfolder first, otherwise you'll get a write error.
Add the library (ZipArchive.lib ) to the project (Project->Add To Project) and compile.
If you wish to convert Visual C++ project using Visual C++ Project Conversion Utility then after converting to properly compile the application you need to remove odbccp32.lib from the project file and comment everything out in ZipArc_TLB.cpp or remove this file from the project files.
Usage
When using the library under Linux you should be aware of a few things:
- after you get the system attributes with CZipFileHeader::GetSystemAttr() function, you need to shift them right by 16 ( e.g. uAttr = header.GetSystemAttr() >> 16 ) - the reason for that is the way the attributes are stored in the archive created under (or for) Linux.
- due to lack of implementation of ZipPlatform::IsDriveRemovable(), which has proven to be a kind of difficult to do, the device containing the archive is always assumed to be removable; the only effect of this is that you need to set iVolumeSize to a value different from 0 when opening with the function CZipArchive::Open() the archive created in tdSpan mode.
Compiling
- the library was tested under g++ version 3.2.2
- First you need to copy the appropriate files (see above)
- If you haven't got the zlib library already installed on your system, you can install it using Makefile in the zlib subdirectory (type make and then make install )
- only static version (you can download a full version of the zlib library from the ZipArchive library site). If you don't want to install the zlib library, you need to include it in the ZipArchive library ( edit the Makefile in the main directory and change comments, so that OBJSZLIB is not an empty value but points to zlib library object files)
- Compile the library by typing make. The resulting file is a static library libziparch.a
- You can copy the library and the headers (if you have an appropriate rights) to /usr/lib and /usr/include/ziparchive (you can change them in Makefile) with the command make install
- Now you can link the library to your application
e.g. with the command (if the library is in the same directory)
g++ $I. -o app app.cpp -lstdc++ -lz libziparch.a
or if you have the library installed in the /usr subdirectories:
g++ $I/usr/include/ziparchive -o app app.cpp -lstdc++ -lz -lziparch
If you haven't got the zlib library installed, you need to omit the switch -lz in the above commands. - There is a test application named zippie.cpp (in stl/zippie which you can compile typing make zippie (providing that you have installed the ZipArchive library). If you haven't got the zlib library installed, you need to switch the comments (comment one line and uncomment another) in the Makefile in the section "zippie:".
- If you wish to uninstall the library type make uninstall
- [Windows only] If your locale is different from English and you wish to use non-English characters in zip files, you need to set your locale with function std::locale::global(std::locale("")) to set it to be the same as your system locale or e.g. std::locale::global(std::locale("French")) to set it to the specified value (do not use _T() macro here when using Unicode); setlocale() function is not sufficient in this case.
- Remember to restore the global locale to the previous value (returned by std::locale::global) after processing (it may affect other parts of your application).
- There is a sample application that compiles under Windows (MSVC) and Linux (see below to find out how to compile it under Linux). This sample application demonstrates most of the ZipArchive library features and is located in stl/zippie.
[Windows only]
- The project that compiles the DLL version of the ZipArchive library needs to have defined ZIP_HAS_DLL, ZIP_BUILD_DLL and for Visual Studio 6.0 also ZLIB_DLL .
- The project that uses the ZipArchive library as the DLL version need to have defined ZIP_HAS_DLL
MFC sample application using ZipArchive library is available separately. Main features:
- MDI application
- multithreaded - you can work with many zip files at one time
- shell integration (remembers the last application used to open zip files and can restore it correctly)
- drag & drop support
- detailed error reports
- you can open and modify SFX archives
- it demonstrates the use of the following functions (most of them are placed in ZipArcDoc.cpp) : CZipArchive::AddNewFile, CZipArchive::Close, CZipArchive::CloseFile, CZipArchive::CloseNewFile, CZipArchive::DeleteFiles, CZipArchive::EnableFindFast, CZipArchive::ExtractFile, CZipArchive::FindFile, CZipArchive::FindMatches, CZipArchive::Flush, CZipArchive::GetArchivePath, CZipArchive::GetCentralDirInfo, CZipArchive::GetCentralDirSize, CZipArchive::GetCurrentDisk, CZipArchive::GetFileInfo, CZipArchive::GetFindFastIndex, CZipArchive::GetGlobalComment, CZipArchive::GetCount, CZipArchive::GetPassword, CZipArchive::GetSpanMode, CZipArchive::IsClosed, CZipArchive::IsReadOnly, CZipArchive::Open, CZipArchive::RenameFile, CZipArchive::PredictExtractedFileName, CZipArchive::SetAdvanced, CZipArchive::SetCallback, CZipArchive::SetFileComment, CZipArchive::SetGlobalComment, CZipArchive::SetIgnoreCRC, CZipArchive::SetPassword, CZipArchive::SetRootPath, CZipArchive::SetSpanCallback, CZipArchive::SetTempPath, CZipArchive::TestFile, CZipArchive::WillBeDuplicated,
CZipFileHeader::IsEncrypted, CZipFileHeader::IsDirectory, CZipFileHeader::GetTime, CZipFileHeader::GetSystemCompatibility, CZipFileHeader::GetSystemAttr, CZipFileHeader::GetSize, CZipFileHeader::GetFileName, CZipFileHeader::GetEffComprSize, CZipFileHeader::GetCompressionRatio, CZipFileHeader::GetComment, CZipFileHeader::CompressionEfficient,
ZipArchive Copyright © 2000 - 2006 Tadeusz Dracz . Generated at Fri Apr 7 13:55:25 2006.