pax_global_header00006660000000000000000000000064136624611430014520gustar00rootroot0000000000000052 comment=6938d8b108b09ebb14ef25542abd2d9108f8e036 quazip-0.9.1/000077500000000000000000000000001366246114300130405ustar00rootroot00000000000000quazip-0.9.1/.gitignore000066400000000000000000000000051366246114300150230ustar00rootroot00000000000000/doc quazip-0.9.1/CMakeLists.txt000066400000000000000000000043061366246114300156030ustar00rootroot00000000000000cmake_minimum_required(VERSION 2.6) project(QuaZip) # CMP0042: Explicitly acknowledge MACOSX_RPATH # (introduced in CMake 2.8.12, enabled by default in CMake 3.0, # and producing a warning when unset since 3.7.1) cmake_policy(SET CMP0042 NEW) set(QUAZIP_LIB_VERSION 0.9.1) set(QUAZIP_LIB_SOVERSION 1) option(BUILD_WITH_QT4 "Build QuaZip with Qt4 no matter if Qt5 was found" OFF) if(NOT BUILD_WITH_QT4) # try Qt5 first, and prefer that if found find_package(Qt5Core QUIET) endif() if(Qt5Core_FOUND) set(CMAKE_CXX_STANDARD 11) set(QTCORE_LIBRARIES ${Qt5Core_LIBRARIES}) set(QUAZIP_LIB_VERSION_SUFFIX 5) # if there is no QT_ROOT, try to deduce it from Qt QtCore include if("${QT_ROOT}" STREQUAL "") set(QT_ROOT ${QT_QTCORE_INCLUDE_DIR}/../..) endif() include_directories(${Qt5Core_INCLUDE_DIRS}) macro(qt_wrap_cpp) qt5_wrap_cpp(${ARGN}) endmacro() else() set(qt_min_version "4.5.0") find_package(Qt4 REQUIRED) set(QT_USE_QTGUI false) include(${QT_USE_FILE}) include_directories(${QT_INCLUDES}) set(QTCORE_LIBRARIES ${QT_QTCORE_LIBRARY}) macro(qt_wrap_cpp) qt4_wrap_cpp(${ARGN}) endmacro() endif() # Use system zlib on unix and Qt ZLIB on Windows find_package(ZLIB REQUIRED) # All build libraries are moved to this directory set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}) set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)") set(LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name" FORCE) set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig" CACHE STRING "Installation directory for pkgconfig (.pc) files" FORCE) set(QUAZIP_LIB_TARGET_NAME quazip${QUAZIP_LIB_VERSION_SUFFIX} CACHE INTERNAL "Target name of libquazip" FORCE) add_subdirectory(quazip) if(UNIX AND NOT APPLE) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/quazip.pc.cmakein ${CMAKE_CURRENT_BINARY_DIR}/quazip.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/quazip.pc DESTINATION "${INSTALL_PKGCONFIG_DIR}") endif() install(FILES QuaZipConfig.cmake DESTINATION ${LIB_DESTINATION}/cmake/QuaZip${QUAZIP_LIB_VERSION_SUFFIX} RENAME QuaZip${QUAZIP_LIB_VERSION_SUFFIX}Config.cmake) quazip-0.9.1/CONTRIBUTING.md000066400000000000000000000346601366246114300153020ustar00rootroot00000000000000Fixed a bug? Implemented a new feature? Want to have it included in QuaZIP? Here's what you need to do. 0. If you don't have a GitHub account, create one. It's ridiculously easy. 1. First, open an [issue](https://github.com/stachenov/quazip/issues). Even if you have already fixed it. It helps to track things because instead of a commit saying “fixed this and that” you have a reference to a full issue description. 2. Next, send a pull request. This is sort of counter-intuitive, so if you never did it, read on. **Contribution guidelines** To avoid spending time on something that may never be accepted, here are some guidelines. 1. Changes should be backwards-compatible. Don't just change method names and their signatures randomly. Don't just remove deprecated features—some of them are there to keep compatibility with old Qt versions. Currently supported are versions since 4.6. 2. If your changes aren't limited to a small fix or a convenience method, discussing them in the issue you just opened (if you didn't, do!) could help to achieve some agreement on what exactly is a good idea in your case. 3. Whether you're fixing a bug or adding a new feature, it's an awesome idea to add a new test in the `qztest` subproject. This way you make sure the bug stays fixed and the feature keeps working. 4. It would be nice if you also update NEWS.txt with whatever changes you propose. Just add another line on top. 5. QuaZIP policies on PR commits are these. Don't squash your commits until the discussion on the PR is over and it's approved. *Do* squash them, however, once it's approved, unless asked otherwise. And finally: rebase, don't merge. QuaZIP keeps mostly linear history. If you have no idea what it's all about, read on. **How to submit a pull request** **What is a PR anyway?** There are numerous sources that describe this already. Ideally, you should familiarize yourself with both GitHub and Git. But you could lack time. Or maybe you don't use Git in your daily work. Or something else. In either case, here are some basics to get you started without spending too much time researching something you might never need again. Pull requests (PRs) are GitHub's way of sending patches to people. Except that instead of sending a patch, you send a full-fledged version control branch that is much easier to integrate than a regular patch. The overall process is that you have a full copy of the repository both at your GitHub account and on your computer. You create a new branch on your computer, make some changes, commit to that branch and finally send these commits to your account. Then, GitHub takes over and offers you to create something like a specialized forum topic with your changes attached to it much like a patch would be attached to an e-mail message. Except that it's actually alive—whatever changes you make later on will cause the patch to be automatically updated with all your changes combined. **Setting up for a PR submission** Here are the steps you need to follow if you're sending your *first* PR to QuaZIP. You don't need to repeat these each time. 0. If you haven't installed Git yet, do so. In Windows, choose the recommended setting for line endings. 1. Go to https://github.com/stachenov/quazip. 2. Click “Fork” in the top-right corner and wait until forking is complete. 3. You should now have a full copy of QuaZIP in your own GitHub account. This may sound like a huge overkill to just send a small patch, but it's actually very convenient once you get used to it. 4. Clone QuaZIP to your computer. Use your own account's repo URL as a source, NOT https://github.com/stachenov/quazip! To do it, run ``` git clone https://github.com/your-user-name-goes-here/quazip ``` This command will create a new `quazip` directory and clone into it. Now you have two QuaZIP repos. One in your GitHub account, accessible to you only via GitHub itself, and another one in the directory that has just been created. Let's call the repo on your PC the local repo. It is rooted at the directory that was created by Git when you ran the above command. Most Git commands from now on should be issued from within this directory unless specified otherwise. 5. Go into the local repo and run ``` git remote add upstream https://github.com/stachenov/quazip ``` This commands tells Git that there is another copy of the same project. Now that copy will be accessible by the name “upstream”. You could use any name here, but “upstream” is a common name for such a typical case. Another typical name is “origin”, which was already added by Git when you ran the “clone” command. Now run ``` git remote -v ``` This command lists the configured remotes: ``` origin https://github.com/your-user-name/quazip (fetch) origin https://github.com/your-user-name/quazip (push) upstream https://github.com/stachenov/quazip (fetch) upstream https://github.com/stachenov/quazip (push) ``` Every remote is listed twice because there are two operations: you can send (push) commits to a remote repo, or you can receive (fetch/pull) commits from one. Of course, you can't commit to the upstream because you have no write permissions for it, but Git doesn't know about it, so it added both lines for the upstream. Just ignore the push one. Now your local repo knows how to exchange commits with your GitHub account and with the main QuaZIP repo. You're all set for submitting your first PR. If you ever wish to submit another PR, no need to do all this again. Except that if you delete your local repo, you'll have to redo steps 4 and 5. But you may need to update your master branch before you start working on another feature for another PR. See “Reintegrating the latest upstream changes” below. **Making changes and submitting a PR** Submitting a PR is easy, but can be confusing first time if you're not familiar with Git. 1. Create a new branch in your local repo. This is very important! Most Git repos, including QuaZIP, have the main branch called “master”. By creating a new branch you tell Git where your changes begin and end. This way GitHub can automatically create a patch containing only your changes. To create a branch, run from your local repo: ``` git checkout -b new-branch-name ``` Name the branch whatever you want, it's totally unimportant as it will be deleted later. If you already have some changes in your working dir, but have not added/committed them, it's still not too late to create a new branch, your changes will be kept. 2. Make whatever changes you want. 3. Run `git diff` to review the changes. 4. Run `git add` with all changed/added files as arguments. `git status` will remind you what files you have changed or added. After you're done, `git status` should show all your files as “changes to be committed”. Note that if you change a file, add it, then change it again, you need to re-run `git add` or you end up committing your file as it was when you first added it (Git remembers its contents at that time). 5. Run `git commit`. Enter a meaningful commit message. See Git docs for examples and recommendations. 6. Run `git log -p`. It shows what changes you made. It's especially useful on Windows where `git diff` might have shown that everything is fine, but `git log -p` mysteriously shows that you have changed every single line of a file. It means you have screwed up line endings. Don't worry, you can overwrite your last commit. Another useful thing to look for is to look for branch names here. Your last commit should have something like `HEAD -> my-feature`, whereas the previous one should have `origin/master`. This is exactly the kind of information that will be used by GitHub. Everything that goes after the `origin/master` commit will be included in the patch you're about to submit. 6. Run ``` git push -u origin your-branch-name ``` This weird command sends your committed changes to your GitHub account. The `-u` option tells Git to remember that your branch goes to your account under the same name so you don't have to type it again. 7. Go to your account's page and open quazip there. You should see a message informing you about the new branch and offering to create a PR. Just do it. Don't be afraid to mess something up as your changes aren't going anywhere yet. If there's something wrong with them, I'll just tell you what and how to fix. **How to fix mistakes** If you have committed your changes, but not yet pushed it, you can always replace the last commit. Just fix your mistakes, `git add` modified files again and then run ``` git commit --amend ``` It will look like a regular commit procedure, except that you're not adding yet another commit to your repo—you're replacing the last one. If you have already pushed the last commit, it's no big deal either. Except that you need to re-push your amended commit to GitHub, and Git by default will not let you do so. Easy to override, though: ``` git push --force-with-lease ``` **Squashing commits** You may end up with a pretty messy history with lots of commits. Before submitting a PR, you may wish to tidy up your history a bit. It's beyond this short tutorial to explain how to rewrite history in Git, but the simplest change you can do is to squash all commits into a single one. Or perhaps squash some of them. Run ``` git rebase -i master ``` This command assumes you never touched the master branch, and all work was done within your own branch. It will then open up an editor with something like ``` pick f564b4c feature pick 0ea95aa oops pick 0cbd876 Fixed, finally ``` The messages and SHA hashes will be different, but you get the list of your changes since your branch diverged from the master. To join all the commits into one, edit like this: ``` pick f564b4c feature s 0ea95aa oops s 0cbd876 Fixed, finally ``` Here, `s` means “squash”, that is, combine with the previous commit. Next, an editor with combined commit message pops up. Edit it into a single coherent message and save. Viola! Now you have just one commit. Note that since this is a kind of history rewrite, just like `--amend`, you'll have to use `--force-with-lease` to push this history again to GitHub. **Making changes after submitting a PR** You can amend commits and squash them after submitting a PR. The PR will be automatically updated by GitHub. Whatever you do, the PR will always display the difference between the master branch and the latest commit on your feature branch. **Discussing and closing the PR** A PR is sort of a patch attached to a specialized forum topic. It can be discussed, various pieces of code can be reviewed, and it ends either by merging the PR, including your changes in the QuaZIP repo, or closing it without merging if your changes are rejected for whatever reason. If the PR is successfully merged, you can safely delete your branch. Locally, it is done with ``` git checkout master git branch -D your-branch-name git branch -dr origin/your-branch-name ``` The first command switches to the master branch (because it would be weird to delete a branch you're currently on), the second one deletes the branch itself, the third one deletes the reference to the remote counterpart in your GitHub account. Note that only the *reference* is deleted here, the branch itself stays alive and well in your account. To delete it, simply go to the PR and there will be a message saying that the PR is merged with the “delete branch” button right next to it. **Reintegrating the latest upstream changes** Suppose some changes were introduced into the master branch while you were working on your feature. With the traditional send-patch-by-email approach, whoever applies that patch must handle all conflicts (rejected hunks) that arise. With Git, you have a way to fix it before even sending the patch (submitting the PR). Another situation when you need to pull in the changes from the upstream repo is when you need to submit your next PR, perhaps years later. You still have your old clone (fork) in your GitHub account, and perhaps even a local one on your computer. However, they are probably terribly outdated by now so you need to update them first. Update procedures are similar in both cases. 1. In either case, you need to make sure you're on the master branch. If it's an old clone, you're probably are, unless you forgot to clean up. If you're working on a feature, you're probably on your feature branch. Make sure your changes are committed before you continue. Then, run ``` git checkout master ``` It will bring you back to the master branch. 2. You need to pull in the changes from the upstream repo. The least destructive way to do it is to fetch these changes first: ``` git fetch upstream ``` This command just fetches data from the upstream repo, but doesn't touch your working files yet. 3. Next, you better make sure you have no changes with `git status`. You probably don't if you remembered not to touch the master branch. 4. Pull in the latest commits from the upstream: ``` git merge upstream/master ``` This will make your master branch identical the one from the upstream. 5. Push these changes to your GitHub account: ``` git push origin master ``` The absence of `-u` means that Git won't remember that the master branch is connected with `origin`. That's a good thing because there are two different remote repos for the master branch, and it's much easier to explicitly specify each time where you want to push it to or pull it from rather than remembering which one of the remotes it's associated with. 6. If you were just updating your outdated repo, the procedure ends here. However, if you were already working on a branch that split off from the master before this update, now you need to somehow merge your changes into the new upstream version. There are two ways to do it: merge and rebase. The QuaZIP way is rebase, so rebase you should do. But first, switch to your branch: ``` git checkout your-feature-branch ``` 7. To merge your changes into the new version, run ``` git rebase master ``` This basically says: take the current branch, detach it from where it split from the master, then reattach it to the tip of the new master branch and replay all the changes that were made, making new commits. This leads you to a linear history, where you branch just continues on from the master, instead of splitting from some old version. If there are merge conflicts, you have to solve them by editing conflicting files, then running `git add` on them (which in this case just says you're done with conflict solving) and finally running `git rebase --continue`. There are much more advanced conflict solving techniques which are, again, beyond the scope of this note. quazip-0.9.1/COPYING000066400000000000000000000610761366246114300141050ustar00rootroot00000000000000The QuaZIP library is licensed under the GNU Lesser General Public License V2.1 plus a static linking exception. STATIC LINKING EXCEPTION The copyright holders give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you must extend this exception to your version of the library. The text of the GNU Lesser General Public License V2.1 follows. GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS quazip-0.9.1/Doxyfile000066400000000000000000002157001366246114300145530ustar00rootroot00000000000000# Doxyfile 1.7.4 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = QuaZIP # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = quazip-0-9 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = doc # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 8 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given extension. # Doxygen has a built-in mapping, but you can override or extend it using this # tag. The format is ext=language, where ext is a file extension, and language # is one of the parsers supported by doxygen: IDL, Java, Javascript, CSharp, C, # C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, C++. For instance to make # doxygen treat .inc files as Fortran files (default is PHP), and .f files as C # (default is Fortran), use: inc=Fortran f=C. Note that for custom extensions # you also need to set FILE_PATTERNS otherwise the files are not read by doxygen. EXTENSION_MAPPING = # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate getter # and setter methods for a property. Setting this option to YES (the default) # will make doxygen replace the get and set methods by a property in the # documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and # unions are shown inside the group in which they are included (e.g. using # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols SYMBOL_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = NO # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to # do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even # if there is only one candidate or it is obvious which candidate to choose # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. The create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = quazip # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = *.cpp \ *.h \ *.dox # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = quazip/unzip.h \ quazip/zip.h \ quazip/ioapi.h \ quazip/minizip_crypt.h \ qztest/ # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = */.moc/* */release/* */debug/* */moc_*.cpp # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = NO # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = NO # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. # It is adviced to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically # have to redo this when upgrading to a newer version of doxygen or when changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the stylesheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely identify # the documentation publisher. This should be a reverse domain-name style # string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values # (range [0,1..20]) that doxygen will group on one line in the generated HTML # documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 4 # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. GENERATE_TREEVIEW = NO # By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, # and Class Hierarchy pages using a tree view instead of an ordered list. USE_INLINE_TREES = NO # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to the # mathjax.org site, so you can quickly see the result without installing # MathJax, but it is strongly recommended to install a local copy of MathJax # before deployment. MATHJAX_RELPATH = http://www.mathjax.org/mathjax # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a PHP enabled web server instead of at the web client # using Javascript. Doxygen will generate the search PHP script and index # file to put on the web server. The advantage of the server # based approach is that it scales better to large projects and allows # full text search. The disadvantages are that it is more difficult to setup # and does not have live searching capabilities. SERVER_BASED_SEARCH = NO #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for # the generated latex document. The footer should contain everything after # the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! LATEX_FOOTER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = qtcore.tags=http://doc.qt.io/qt-5.9/ # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 0 # By default doxygen will write a font called Helvetica to the output # directory and reference it in all dot files that doxygen generates. # When you want a differently looking font you can specify the font name # using DOT_FONTNAME. You need to make sure dot is able to find the font, # which can be done by putting it in a standard location or by setting the # DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory # containing the font. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the output directory to look for the # FreeSans.ttf font (which doxygen will put there itself). If you specify a # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES quazip-0.9.1/NEWS.txt000066400000000000000000000173051366246114300143630ustar00rootroot00000000000000QuaZIP changes * 2020-04-29 0.9 * Support for extended timestamps * Various contributed CMake fixes * 2019-05-27 0.8.1 * CMake regression fix * 2019-05-23 0.8 * Support for UTF-8 in file names and comments (Denis Zavorotnyy) * get/setOsCode(), get/setDefaultOsCode() * Fixed Z_STREAM_END handling in QuaZioDevice * 2018-06-13 0.7.6 * Fixed the Zip Slip vulnerability in JlCompress * Renamed crypt.h to minizip_crypt.h to avoid conflicts * 2018-05-20 0.7.5 * Fixed target_link_libraries call in CMakeLists * Worked around a Qt 4.6 bug (QTBUG-15421) screwing up hidden files handling in JlCompress::compressDir() * Removed Q_FOREACH uses to avoid conflicts (SF patch #32) * 2017-02-05 0.7.4 * Static analysis patch from Intel Deutschland GmbH * Replaced UNUSED with QUAZIP_UNUSED to avoid name clashes * Minor bug fixes * 2017-02-05 0.7.3 * Symlink handling * Static linking exception for LGPL * Minor bug fixes * 2016-03-29 0.7.2 * New JlCompress methods (QIODevice*-based API by Lukasz Kwiecinski) * Implemented QuaZioDevice::atEnd() and bytesAvailable()--these might break ABI, but pretty unlikely. * 2015-01-07 0.7.1 * Fixed licensing issues (bug #45). * Added the convenience method QuaZipFileInfo::isEncrypted(). * 2014-07-24 0.7 * It is now possible to write ZIP files to sequential devices like sockets (only in mdCreate mode, so no self-extract, sorry). * A few zip64 fixes. * Several bug fixes and portability improvements. * 2014-02-09 0.6.2 * QuaZipNewInfo / QuaZipFileInfo64 now provide API to access/set NTFS time stamps - useful even on non-NTFS systems if you need more precise dates and times than default ones. * QuaZipNewInfo may now be initialized from QuaZipFileInfo64. * No more crashes when using QSaveFile as QIODevice for ZIP. * The new QuaZip::setAutoClose() method allows to leave the QIODevice open when you close the QuaZip instance. * qztest now depends on quazip, no longer breaking the build. * 2014-01-26 0.6.1 * Improved zip64 support. * A LOT more tests thanks to g++ --coverage / lcov. * JlCompress extraction methods now create files with default permissions if they are zero in the original archive. * Some QuaZipDir fixes (thanks to the new tests). * 2014-01-22 0.6 * Minizip updated to 1.1 (with all the necessary modifications re-done), and that means that... * the long-awaited zip64 support is now available! * A few rather minor fixes. * 2014-01-19 0.5.2 * Some minor bug fixes. * API to access file permissions subfield of the external attributes. * MS VS 2012 Express support. * API to set the default codec used to encode/decode file names (mainly for use by various wrappers such as JlCompress, when you don't have direct access to the underlying QuaZip instance). * 2013-03-02 0.5.1 * Lots of QuaZipDir fixes, thanks to all bug reporters. * Full Qt Creator support. * MS VS 2010 Express support. * Qt5 support (didn't need any source code changes anyway). * Lots of minor bug fixes. * 2012-09-07 0.5 * Added run_moc.bat files for building under Windows in case Qt integration is not available (e. g. VS 2008 Express). * Added the QuaZipDir class to simplify ZIP navigation in terms of directories. * Added the QuaGzipFile class for working with GZIP archives. It was added as a bonus since it has nothing to do with the main purpose of the library. It probably won't get any major improvements, although minor bug fixes are possible. * Added the QuaZIODevice class for working with zlib compression. It has nothing to do with the ZIP format, and therefore the same notice as for the QuaGzipFile applies. * The global comment is no longer erased when adding files to an archive. * Many bug fixes. * 2012-01-14 0.4.4 * Fixed isSequential() test that was causing open() failures on Unix. * Fixed sub-directory compressing in JlCompress. * Added MS VS 2008 solution, compatible with the binary Qt distribution (tested on MS VS 2008 Express, had to run MOC manually due to the lack of plugin in Express). * Fixed extracting directories in JlCompress. * Fixed JlCompress.h includes in the test suite, which used lowercase names thus breaking on case-sensitive systems. * Implemented missing QuaZipFile::getZip() that was only declared. * Fixed reopening closed files. * Fixed possible memory leak in case of open error. * 2011-09-09 0.4.3 * New test suite using QTestLib. * Fixed bytesAvailable(), pos() and atEnd(). * Added ZIP v1.0 support and disabling data descriptor for compatibility with some older software. * Fixed DLL export/import issues for some symbols. * Added QUAZIP_STATIC macro for compiling as a static library or directly including the source. * Added getFileNameList() and getFileInfoList() convenience functions. * Added some buffering to JlCompress to improve performance. * 2011-08-10 0.4.2 * Cmake patch (thanks to Bernhard Rosenkraenzer). * Symbian patch (thanks to Hamish Willee). * Documented the multiple files limitation of QuaZipFile. * Fixed relative paths handling in JlCompress. * Fixed linking to MinGW zlib. * 2011-05-26 0.4.1 * License statement updated to avoid confusion. GPL license removed for the very same reason. * Parts of original package are now clearly marked as modified, just as their license requires. * 2011-05-23 0.4 * QuaZip and QuaZipFile classes now use the Pimpl idiom. This means that future releases will probably be binary compatible with this one, but it also means that this one is binary incompatible with the old ones. * IO API has been rewritten using QIODevice instead of standard C library. Among other things it means that QuaZip now supports files up to 4 GB in size instead of 2 GB. * Added QuaZip methods allowing access to ZIP files represented by any seekable QIODevice implementation (QBuffer is a good example). * 2010-07-23 0.3 * Fixed getComment() for global comments. * Added some useful classes for calculating checksums (thanks to Adam Walczak). * Added some utility classes for working with whole directories (thanks to Roberto Pompermaier). It would be nice if someone documents these in English, though. * Probably fixed some problems with passwords (thanks to Vasiliy Sorokin). I didn't test it, though. * 2008-09-17 0.2.3 * Fixed license notices in sources. * SVN * Fixed a small bug in QuaZipFile::atEnd(). * 2007-01-16 0.2.2 * Added LGPL as alternative license. * Added FAQ documentation page. * 2006-03-21 0.2.1 * Fixed setCommentCodec() bug. * Fixed bug that set month 1-12 instead of 0-11, as specified in zip.h. * Added workaround for Qt's bug that caused wrong timestamps. * Few documentation fixes and cosmetic changes. * 2005-07-08 0.2 * Write support. * Extended QuaZipFile API, including size(), *pos() functions. * Support for comments encoding/decoding. * 2005-07-01 0.1 * Initial version. quazip-0.9.1/QuaZipConfig.cmake000066400000000000000000000035211366246114300164020ustar00rootroot00000000000000# QUAZIP_FOUND - QuaZip library was found # QUAZIP_INCLUDE_DIR - Path to QuaZip include dir # QUAZIP_INCLUDE_DIRS - Path to QuaZip and zlib include dir (combined from QUAZIP_INCLUDE_DIR + ZLIB_INCLUDE_DIR) # QUAZIP_LIBRARIES - List of QuaZip libraries # QUAZIP_ZLIB_INCLUDE_DIR - The include dir of zlib headers IF (QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) # in cache already SET(QUAZIP_FOUND TRUE) ELSE (QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) IF (Qt5Core_FOUND) set(QUAZIP_LIB_VERSION_SUFFIX 5) ENDIF() IF (WIN32) FIND_PATH(QUAZIP_LIBRARY_DIR WIN32_DEBUG_POSTFIX d NAMES libquazip${QUAZIP_LIB_VERSION_SUFFIX}.dll HINTS "C:/Programme/" "C:/Program Files" PATH_SUFFIXES QuaZip/lib ) FIND_LIBRARY(QUAZIP_LIBRARIES NAMES libquazip${QUAZIP_LIB_VERSION_SUFFIX}.dll HINTS ${QUAZIP_LIBRARY_DIR}) FIND_PATH(QUAZIP_INCLUDE_DIR NAMES quazip.h HINTS ${QUAZIP_LIBRARY_DIR}/../ PATH_SUFFIXES include/quazip${QUAZIP_LIB_VERSION_SUFFIX}) FIND_PATH(QUAZIP_ZLIB_INCLUDE_DIR NAMES zlib.h) ELSE(WIN32) FIND_PACKAGE(PkgConfig) # pkg_check_modules(PC_QCA2 QUIET qca2) pkg_check_modules(PC_QUAZIP quazip) FIND_LIBRARY(QUAZIP_LIBRARIES WIN32_DEBUG_POSTFIX d NAMES quazip${QUAZIP_LIB_VERSION_SUFFIX} HINTS /usr/lib /usr/lib64 ) FIND_PATH(QUAZIP_INCLUDE_DIR quazip.h HINTS /usr/include /usr/local/include PATH_SUFFIXES quazip${QUAZIP_LIB_VERSION_SUFFIX} ) FIND_PATH(QUAZIP_ZLIB_INCLUDE_DIR zlib.h HINTS /usr/include /usr/local/include) ENDIF (WIN32) INCLUDE(FindPackageHandleStandardArgs) SET(QUAZIP_INCLUDE_DIRS ${QUAZIP_INCLUDE_DIR} ${QUAZIP_ZLIB_INCLUDE_DIR}) find_package_handle_standard_args(QUAZIP DEFAULT_MSG QUAZIP_LIBRARIES QUAZIP_INCLUDE_DIR QUAZIP_ZLIB_INCLUDE_DIR QUAZIP_INCLUDE_DIRS) ENDIF (QUAZIP_INCLUDE_DIRS AND QUAZIP_LIBRARIES) quazip-0.9.1/README.md000066400000000000000000000013751366246114300143250ustar00rootroot00000000000000QuaZIP is the C++ wrapper for Gilles Vollant's ZIP/UNZIP package (AKA Minizip) using Trolltech's Qt library. If you need to write files to a ZIP archive or read files from one using QIODevice API, QuaZIP is exactly the kind of tool you need. See [the documentation](https://stachenov.github.io/quazip/) for details. Want to report a bug or ask for a feature? Open an [issue](https://github.com/stachenov/quazip/issues). Want to fix a bug or implement a new feature? See [CONTRIBUTING.md](CONTRIBUTING.md). Copyright notice: Copyright (C) 2005-2018 Sergey A. Tachenov Distributed under LGPL, full details in the COPYING file. Original ZIP package is copyrighted by Gilles Vollant, see quazip/(un)zip.h files for details, but basically it's the zlib license. quazip-0.9.1/includes.pri000066400000000000000000000002521366246114300153610ustar00rootroot00000000000000OBJECTS_DIR = .obj MOC_DIR = .moc unix { isEmpty(PREFIX): PREFIX=/usr/local } win32 { isEmpty(PREFIX): warning("PREFIX unspecified, make install won't work") } quazip-0.9.1/quazip.pc.cmakein000066400000000000000000000003771366246114300163120ustar00rootroot00000000000000prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${prefix}/lib@LIB_SUFFIX@ includedir=${prefix}/include Name: Quazip Description: Quazip Library Version: @QUAZIP_LIB_VERSION@ Libs: -lquazip@QUAZIP_LIB_VERSION_SUFFIX@ Cflags: Requires: Qt5Core quazip-0.9.1/quazip.pri000066400000000000000000000001151366246114300150620ustar00rootroot00000000000000INCLUDEPATH+=$$PWD DEPENDPATH+=$$PWD/quazip include($$PWD/quazip/quazip.pri) quazip-0.9.1/quazip.pro000066400000000000000000000000771366246114300150770ustar00rootroot00000000000000TEMPLATE=subdirs SUBDIRS=quazip qztest qztest.depends = quazip quazip-0.9.1/quazip.sln000066400000000000000000000037251366246114300150760ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.40629.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "quazip", "quazip\quazip.vcxproj", "{E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qztest", "qztest\qztest.vcxproj", "{7632B767-D089-4F15-8B1E-C4B3F9EBF592}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Debug|Win32.ActiveCfg = Debug|Win32 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Debug|Win32.Build.0 = Debug|Win32 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Debug|x64.ActiveCfg = Debug|x64 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Debug|x64.Build.0 = Debug|x64 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Release|Win32.ActiveCfg = Release|Win32 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Release|Win32.Build.0 = Release|Win32 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Release|x64.ActiveCfg = Release|x64 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Release|x64.Build.0 = Release|x64 {7632B767-D089-4F15-8B1E-C4B3F9EBF592}.Debug|Win32.ActiveCfg = Debug|Win32 {7632B767-D089-4F15-8B1E-C4B3F9EBF592}.Debug|Win32.Build.0 = Debug|Win32 {7632B767-D089-4F15-8B1E-C4B3F9EBF592}.Debug|x64.ActiveCfg = Debug|Win32 {7632B767-D089-4F15-8B1E-C4B3F9EBF592}.Release|Win32.ActiveCfg = Release|Win32 {7632B767-D089-4F15-8B1E-C4B3F9EBF592}.Release|Win32.Build.0 = Release|Win32 {7632B767-D089-4F15-8B1E-C4B3F9EBF592}.Release|x64.ActiveCfg = Release|x64 {7632B767-D089-4F15-8B1E-C4B3F9EBF592}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal quazip-0.9.1/quazip/000077500000000000000000000000001366246114300143515ustar00rootroot00000000000000quazip-0.9.1/quazip/CMakeLists.txt000066400000000000000000000031411366246114300171100ustar00rootroot00000000000000file(GLOB SRCS "*.c" "*.cpp") file(GLOB PUBLIC_HEADERS "*.h") set(QUAZIP_LIB_VERSION 1.0.0) set(QUAZIP_LIB_SOVERSION 1) # Must be added to enable export macro ADD_DEFINITIONS(-DQUAZIP_BUILD) qt_wrap_cpp(MOC_SRCS ${PUBLIC_HEADERS}) set(SRCS ${SRCS} ${MOC_SRCS}) add_library(${QUAZIP_LIB_TARGET_NAME} SHARED ${SRCS}) add_library(quazip_static STATIC ${SRCS}) # Windows uses .lib extension for both static and shared library # *nix systems use different extensions for SHARED and STATIC library and by convention both libraries have the same name if (NOT WIN32) set_target_properties(quazip_static PROPERTIES OUTPUT_NAME quazip${QUAZIP_LIB_VERSION_SUFFIX}) endif () target_include_directories(${QUAZIP_LIB_TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${ZLIB_INCLUDE_DIRS}) target_include_directories(quazip_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${ZLIB_INCLUDE_DIRS}) set_target_properties(${QUAZIP_LIB_TARGET_NAME} quazip_static PROPERTIES VERSION ${QUAZIP_LIB_VERSION} SOVERSION ${QUAZIP_LIB_SOVERSION} DEBUG_POSTFIX d) # Link against ZLIB_LIBRARIES if needed (on Windows this variable is empty) target_link_libraries(${QUAZIP_LIB_TARGET_NAME} ${QT_QTMAIN_LIBRARY} ${QTCORE_LIBRARIES} ${ZLIB_LIBRARIES}) target_link_libraries(quazip_static ${QT_QTMAIN_LIBRARY} ${QTCORE_LIBRARIES} ${ZLIB_LIBRARIES}) install(FILES ${PUBLIC_HEADERS} DESTINATION include/quazip${QUAZIP_LIB_VERSION_SUFFIX}) install(TARGETS ${QUAZIP_LIB_TARGET_NAME} quazip_static LIBRARY DESTINATION ${LIB_DESTINATION} ARCHIVE DESTINATION ${LIB_DESTINATION} RUNTIME DESTINATION ${LIB_DESTINATION}) quazip-0.9.1/quazip/JlCompress.cpp000066400000000000000000000320161366246114300171400ustar00rootroot00000000000000/* Copyright (C) 2010 Roberto Pompermaier Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include "JlCompress.h" static bool copyData(QIODevice &inFile, QIODevice &outFile) { while (!inFile.atEnd()) { char buf[4096]; qint64 readLen = inFile.read(buf, 4096); if (readLen <= 0) return false; if (outFile.write(buf, readLen) != readLen) return false; } return true; } bool JlCompress::compressFile(QuaZip* zip, QString fileName, QString fileDest) { // zip: oggetto dove aggiungere il file // fileName: nome del file reale // fileDest: nome del file all'interno del file compresso // Controllo l'apertura dello zip if (!zip) return false; if (zip->getMode()!=QuaZip::mdCreate && zip->getMode()!=QuaZip::mdAppend && zip->getMode()!=QuaZip::mdAdd) return false; // Apro il file originale QFile inFile; inFile.setFileName(fileName); if(!inFile.open(QIODevice::ReadOnly)) return false; // Apro il file risulato QuaZipFile outFile(zip); if(!outFile.open(QIODevice::WriteOnly, QuaZipNewInfo(fileDest, inFile.fileName()))) return false; // Copio i dati if (!copyData(inFile, outFile) || outFile.getZipError()!=UNZ_OK) { return false; } // Chiudo i file outFile.close(); if (outFile.getZipError()!=UNZ_OK) return false; inFile.close(); return true; } bool JlCompress::compressSubDir(QuaZip* zip, QString dir, QString origDir, bool recursive, QDir::Filters filters) { // zip: oggetto dove aggiungere il file // dir: cartella reale corrente // origDir: cartella reale originale // (path(dir)-path(origDir)) = path interno all'oggetto zip // Controllo l'apertura dello zip if (!zip) return false; if (zip->getMode()!=QuaZip::mdCreate && zip->getMode()!=QuaZip::mdAppend && zip->getMode()!=QuaZip::mdAdd) return false; // Controllo la cartella QDir directory(dir); if (!directory.exists()) return false; QDir origDirectory(origDir); if (dir != origDir) { QuaZipFile dirZipFile(zip); if (!dirZipFile.open(QIODevice::WriteOnly, QuaZipNewInfo(origDirectory.relativeFilePath(dir) + QLatin1String("/"), dir), 0, 0, 0)) { return false; } dirZipFile.close(); } // Se comprimo anche le sotto cartelle if (recursive) { // Per ogni sotto cartella QFileInfoList files = directory.entryInfoList(QDir::AllDirs|QDir::NoDotAndDotDot|filters); for (int index = 0; index < files.size(); ++index ) { const QFileInfo & file( files.at( index ) ); #if QT_VERSION < QT_VERSION_CHECK(4, 7, 4) if (!file.isDir()) continue; #endif // Comprimo la sotto cartella if(!compressSubDir(zip,file.absoluteFilePath(),origDir,recursive,filters)) return false; } } // Per ogni file nella cartella QFileInfoList files = directory.entryInfoList(QDir::Files|filters); for (int index = 0; index < files.size(); ++index ) { const QFileInfo & file( files.at( index ) ); // Se non e un file o e il file compresso che sto creando if(!file.isFile()||file.absoluteFilePath()==zip->getZipName()) continue; // Creo il nome relativo da usare all'interno del file compresso QString filename = origDirectory.relativeFilePath(file.absoluteFilePath()); // Comprimo il file if (!compressFile(zip,file.absoluteFilePath(),filename)) return false; } return true; } bool JlCompress::extractFile(QuaZip* zip, QString fileName, QString fileDest) { // zip: oggetto dove aggiungere il file // filename: nome del file reale // fileincompress: nome del file all'interno del file compresso // Controllo l'apertura dello zip if (!zip) return false; if (zip->getMode()!=QuaZip::mdUnzip) return false; // Apro il file compresso if (!fileName.isEmpty()) zip->setCurrentFile(fileName); QuaZipFile inFile(zip); if(!inFile.open(QIODevice::ReadOnly) || inFile.getZipError()!=UNZ_OK) return false; // Controllo esistenza cartella file risultato QDir curDir; if (fileDest.endsWith(QLatin1String("/"))) { if (!curDir.mkpath(fileDest)) { return false; } } else { if (!curDir.mkpath(QFileInfo(fileDest).absolutePath())) { return false; } } QuaZipFileInfo64 info; if (!zip->getCurrentFileInfo(&info)) return false; QFile::Permissions srcPerm = info.getPermissions(); if (fileDest.endsWith(QLatin1String("/")) && QFileInfo(fileDest).isDir()) { if (srcPerm != 0) { QFile(fileDest).setPermissions(srcPerm); } return true; } // Apro il file risultato QFile outFile; outFile.setFileName(fileDest); if(!outFile.open(QIODevice::WriteOnly)) return false; // Copio i dati if (!copyData(inFile, outFile) || inFile.getZipError()!=UNZ_OK) { outFile.close(); removeFile(QStringList(fileDest)); return false; } outFile.close(); // Chiudo i file inFile.close(); if (inFile.getZipError()!=UNZ_OK) { removeFile(QStringList(fileDest)); return false; } if (srcPerm != 0) { outFile.setPermissions(srcPerm); } return true; } bool JlCompress::removeFile(QStringList listFile) { bool ret = true; // Per ogni file for (int i=0; iopen(QuaZip::mdUnzip)) { delete zip; return QStringList(); } // Estraggo i nomi dei file QStringList lst; QuaZipFileInfo64 info; for(bool more=zip->goToFirstFile(); more; more=zip->goToNextFile()) { if(!zip->getCurrentFileInfo(&info)) { delete zip; return QStringList(); } lst << info.name; //info.name.toLocal8Bit().constData() } // Chiudo il file zip zip->close(); if(zip->getZipError()!=0) { delete zip; return QStringList(); } delete zip; return lst; } QStringList JlCompress::extractDir(QIODevice* ioDevice, QTextCodec* fileNameCodec, QString dir) { QuaZip zip(ioDevice); if (fileNameCodec) zip.setFileNameCodec(fileNameCodec); return extractDir(zip, dir); } QStringList JlCompress::extractDir(QIODevice *ioDevice, QString dir) { return extractDir(ioDevice, NULL, dir); } QStringList JlCompress::getFileList(QIODevice *ioDevice) { QuaZip *zip = new QuaZip(ioDevice); return getFileList(zip); } QString JlCompress::extractFile(QIODevice *ioDevice, QString fileName, QString fileDest) { QuaZip zip(ioDevice); return extractFile(zip, fileName, fileDest); } QStringList JlCompress::extractFiles(QIODevice *ioDevice, QStringList files, QString dir) { QuaZip zip(ioDevice); return extractFiles(zip, files, dir); } quazip-0.9.1/quazip/JlCompress.h000066400000000000000000000215721366246114300166120ustar00rootroot00000000000000#ifndef JLCOMPRESSFOLDER_H_ #define JLCOMPRESSFOLDER_H_ /* Copyright (C) 2010 Roberto Pompermaier Copyright (C) 2005-2016 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include "quazip.h" #include "quazipfile.h" #include "quazipfileinfo.h" #include #include #include #include #include /// Utility class for typical operations. /** This class contains a number of useful static functions to perform simple operations, such as mass ZIP packing or extraction. */ class QUAZIP_EXPORT JlCompress { private: static QStringList extractDir(QuaZip &zip, const QString &dir); static QStringList getFileList(QuaZip *zip); static QString extractFile(QuaZip &zip, QString fileName, QString fileDest); static QStringList extractFiles(QuaZip &zip, const QStringList &files, const QString &dir); /// Compress a single file. /** \param zip Opened zip to compress the file to. \param fileName The full path to the source file. \param fileDest The full name of the file inside the archive. \return true if success, false otherwise. */ static bool compressFile(QuaZip* zip, QString fileName, QString fileDest); /// Compress a subdirectory. /** \param parentZip Opened zip containing the parent directory. \param dir The full path to the directory to pack. \param parentDir The full path to the directory corresponding to the root of the ZIP. \param recursive Whether to pack sub-directories as well or only files. \return true if success, false otherwise. */ static bool compressSubDir(QuaZip* parentZip, QString dir, QString parentDir, bool recursive, QDir::Filters filters); /// Extract a single file. /** \param zip The opened zip archive to extract from. \param fileName The full name of the file to extract. \param fileDest The full path to the destination file. \return true if success, false otherwise. */ static bool extractFile(QuaZip* zip, QString fileName, QString fileDest); /// Remove some files. /** \param listFile The list of files to remove. \return true if success, false otherwise. */ static bool removeFile(QStringList listFile); public: /// Compress a single file. /** \param fileCompressed The name of the archive. \param file The file to compress. \return true if success, false otherwise. */ static bool compressFile(QString fileCompressed, QString file); /// Compress a list of files. /** \param fileCompressed The name of the archive. \param files The file list to compress. \return true if success, false otherwise. */ static bool compressFiles(QString fileCompressed, QStringList files); /// Compress a whole directory. /** Does not compress hidden files. See compressDir(QString, QString, bool, QDir::Filters). \param fileCompressed The name of the archive. \param dir The directory to compress. \param recursive Whether to pack the subdirectories as well, or just regular files. \return true if success, false otherwise. */ static bool compressDir(QString fileCompressed, QString dir = QString(), bool recursive = true); /** * @brief Compress a whole directory. * * Unless filters are specified explicitly, packs * only regular non-hidden files (and subdirs, if @c recursive is true). * If filters are specified, they are OR-combined with * %QDir::AllDirs|%QDir::NoDotAndDotDot when searching for dirs * and with QDir::Files when searching for files. * * @param fileCompressed path to the resulting archive * @param dir path to the directory being compressed * @param recursive if true, then the subdirectories are packed as well * @param filters what to pack, filters are applied both when searching * for subdirs (if packing recursively) and when looking for files to pack * @return true on success, false otherwise */ static bool compressDir(QString fileCompressed, QString dir, bool recursive, QDir::Filters filters); public: /// Extract a single file. /** \param fileCompressed The name of the archive. \param fileName The file to extract. \param fileDest The destination file, assumed to be identical to \a file if left empty. \return The list of the full paths of the files extracted, empty on failure. */ static QString extractFile(QString fileCompressed, QString fileName, QString fileDest = QString()); /// Extract a list of files. /** \param fileCompressed The name of the archive. \param files The file list to extract. \param dir The directory to put the files to, the current directory if left empty. \return The list of the full paths of the files extracted, empty on failure. */ static QStringList extractFiles(QString fileCompressed, QStringList files, QString dir = QString()); /// Extract a whole archive. /** \param fileCompressed The name of the archive. \param dir The directory to extract to, the current directory if left empty. \return The list of the full paths of the files extracted, empty on failure. */ static QStringList extractDir(QString fileCompressed, QString dir = QString()); /// Extract a whole archive. /** \param fileCompressed The name of the archive. \param fileNameCodec The codec to use for file names. \param dir The directory to extract to, the current directory if left empty. \return The list of the full paths of the files extracted, empty on failure. */ static QStringList extractDir(QString fileCompressed, QTextCodec* fileNameCodec, QString dir = QString()); /// Get the file list. /** \return The list of the files in the archive, or, more precisely, the list of the entries, including both files and directories if they are present separately. */ static QStringList getFileList(QString fileCompressed); /// Extract a single file. /** \param ioDevice pointer to device with compressed data. \param fileName The file to extract. \param fileDest The destination file, assumed to be identical to \a file if left empty. \return The list of the full paths of the files extracted, empty on failure. */ static QString extractFile(QIODevice *ioDevice, QString fileName, QString fileDest = QString()); /// Extract a list of files. /** \param ioDevice pointer to device with compressed data. \param files The file list to extract. \param dir The directory to put the files to, the current directory if left empty. \return The list of the full paths of the files extracted, empty on failure. */ static QStringList extractFiles(QIODevice *ioDevice, QStringList files, QString dir = QString()); /// Extract a whole archive. /** \param ioDevice pointer to device with compressed data. \param dir The directory to extract to, the current directory if left empty. \return The list of the full paths of the files extracted, empty on failure. */ static QStringList extractDir(QIODevice *ioDevice, QString dir = QString()); /// Extract a whole archive. /** \param ioDevice pointer to device with compressed data. \param fileNameCodec The codec to use for file names. \param dir The directory to extract to, the current directory if left empty. \return The list of the full paths of the files extracted, empty on failure. */ static QStringList extractDir(QIODevice* ioDevice, QTextCodec* fileNameCodec, QString dir = QString()); /// Get the file list. /** \return The list of the files in the archive, or, more precisely, the list of the entries, including both files and directories if they are present separately. */ static QStringList getFileList(QIODevice *ioDevice); }; #endif /* JLCOMPRESSFOLDER_H_ */ quazip-0.9.1/quazip/debian/000077500000000000000000000000001366246114300155735ustar00rootroot00000000000000quazip-0.9.1/quazip/debian/libquazip0.symbols000066400000000000000000000145121366246114300212700ustar00rootroot00000000000000libquazip.so.0 libquazip0 #MINVER# _Z24qiodevice_open_file_funcPvS_i@Base 0.4.4 _Z24qiodevice_read_file_funcPvS_S_m@Base 0.4.4 _Z24qiodevice_seek_file_funcPvS_mi@Base 0.4.4 _Z24qiodevice_tell_file_funcPvS_@Base 0.4.4 _Z25qiodevice_close_file_funcPvS_@Base 0.4.4 _Z25qiodevice_error_file_funcPvS_@Base 0.4.4 _Z25qiodevice_write_file_funcPvS_PKvm@Base 0.4.4 _ZN10JlCompress10extractDirE7QStringS0_@Base 0.4.4 _ZN10JlCompress11compressDirE7QStringS0_b@Base 0.4.4 _ZN10JlCompress11extractFileE7QStringS0_S0_@Base 0.4.4 _ZN10JlCompress11getFileListE7QString@Base 0.4.4 _ZN10JlCompress12compressFileE7QStringS0_@Base 0.4.4 _ZN10JlCompress12extractFilesE7QString11QStringListS0_@Base 0.4.4 _ZN10JlCompress13compressFilesE7QString11QStringList@Base 0.4.4 _ZN10QuaAdler325resetEv@Base 0.4.4 _ZN10QuaAdler325valueEv@Base 0.4.4 _ZN10QuaAdler326updateERK10QByteArray@Base 0.4.4 _ZN10QuaAdler329calculateERK10QByteArray@Base 0.4.4 _ZN10QuaAdler32C1Ev@Base 0.4.4 _ZN10QuaAdler32C2Ev@Base 0.4.4 _ZN10QuaZipFile10setZipNameERK7QString@Base 0.4.4 _ZN10QuaZipFile11getFileInfoEP14QuaZipFileInfo@Base 0.4.4 _ZN10QuaZipFile11setFileNameERK7QStringN6QuaZip15CaseSensitivityE@Base 0.4.4 _ZN10QuaZipFile4openE6QFlagsIN9QIODevice12OpenModeFlagEE@Base 0.4.4 _ZN10QuaZipFile4openE6QFlagsIN9QIODevice12OpenModeFlagEEPiS4_bPKc@Base 0.4.4 _ZN10QuaZipFile4openE6QFlagsIN9QIODevice12OpenModeFlagEERK13QuaZipNewInfoPKcjiibiii@Base 0.4.4 _ZN10QuaZipFile5closeEv@Base 0.4.4 _ZN10QuaZipFile6setZipEP6QuaZip@Base 0.4.4 _ZN10QuaZipFile8readDataEPcx@Base 0.4.4 _ZN10QuaZipFile9writeDataEPKcx@Base 0.4.4 _ZN10QuaZipFileC1EP6QuaZipP7QObject@Base 0.4.4 _ZN10QuaZipFileC1EP7QObject@Base 0.4.4 _ZN10QuaZipFileC1ERK7QStringP7QObject@Base 0.4.4 _ZN10QuaZipFileC1ERK7QStringS2_N6QuaZip15CaseSensitivityEP7QObject@Base 0.4.4 _ZN10QuaZipFileC1Ev@Base 0.4.4 _ZN10QuaZipFileC2EP6QuaZipP7QObject@Base 0.4.4 _ZN10QuaZipFileC2EP7QObject@Base 0.4.4 _ZN10QuaZipFileC2ERK7QStringP7QObject@Base 0.4.4 _ZN10QuaZipFileC2ERK7QStringS2_N6QuaZip15CaseSensitivityEP7QObject@Base 0.4.4 _ZN10QuaZipFileC2Ev@Base 0.4.4 _ZN10QuaZipFileD0Ev@Base 0.4.4 _ZN10QuaZipFileD1Ev@Base 0.4.4 _ZN10QuaZipFileD2Ev@Base 0.4.4 _ZN13QuaZipNewInfo15setFileDateTimeERK7QString@Base 0.4.4 _ZN13QuaZipNewInfoC1ERK7QString@Base 0.4.4 _ZN13QuaZipNewInfoC1ERK7QStringS2_@Base 0.4.4 _ZN13QuaZipNewInfoC2ERK7QString@Base 0.4.4 _ZN13QuaZipNewInfoC2ERK7QStringS2_@Base 0.4.4 _ZN13QuaZipNewInfoD1Ev@Base 0.4.4 _ZN13QuaZipNewInfoD2Ev@Base 0.4.4 _ZN14QuaZipFileInfoD1Ev@Base 0.4.4 _ZN14QuaZipFileInfoD2Ev@Base 0.4.4 _ZN6QuaZip10getUnzFileEv@Base 0.4.4 _ZN6QuaZip10getZipFileEv@Base 0.4.4 _ZN6QuaZip10setCommentERK7QString@Base 0.4.4 _ZN6QuaZip10setZipNameERK7QString@Base 0.4.4 _ZN6QuaZip11setIoDeviceEP9QIODevice@Base 0.4.4 _ZN6QuaZip12goToNextFileEv@Base 0.4.4 _ZN6QuaZip13goToFirstFileEv@Base 0.4.4 _ZN6QuaZip14setCurrentFileERK7QStringNS_15CaseSensitivityE@Base 0.4.4 _ZN6QuaZip15setCommentCodecEP10QTextCodec@Base 0.4.4 _ZN6QuaZip15setCommentCodecEPKc@Base 0.4.4 _ZN6QuaZip16setFileNameCodecEP10QTextCodec@Base 0.4.4 _ZN6QuaZip16setFileNameCodecEPKc@Base 0.4.4 _ZN6QuaZip31setDataDescriptorWritingEnabledEb@Base 0.4.4 _ZN6QuaZip4openENS_4ModeEP19zlib_filefunc_def_s@Base 0.4.4 _ZN6QuaZip5closeEv@Base 0.4.4 _ZN6QuaZipC1EP9QIODevice@Base 0.4.4 _ZN6QuaZipC1ERK7QString@Base 0.4.4 _ZN6QuaZipC1Ev@Base 0.4.4 _ZN6QuaZipC2EP9QIODevice@Base 0.4.4 _ZN6QuaZipC2ERK7QString@Base 0.4.4 _ZN6QuaZipC2Ev@Base 0.4.4 _ZN6QuaZipD1Ev@Base 0.4.4 _ZN6QuaZipD2Ev@Base 0.4.4 _ZN7QStringD1Ev@Base 0.4.4 _ZN7QStringD2Ev@Base 0.4.4 _ZN8QuaCrc325resetEv@Base 0.4.4 _ZN8QuaCrc325valueEv@Base 0.4.4 _ZN8QuaCrc326updateERK10QByteArray@Base 0.4.4 _ZN8QuaCrc329calculateERK10QByteArray@Base 0.4.4 _ZN8QuaCrc32C1Ev@Base 0.4.4 _ZN8QuaCrc32C2Ev@Base 0.4.4 _ZNK10QuaZipFile10getZipNameEv@Base 0.4.4 _ZNK10QuaZipFile10metaObjectEv@Base 0.4.4 _ZNK10QuaZipFile11getFileNameEv@Base 0.4.4 _ZNK10QuaZipFile11getZipErrorEv@Base 0.4.4 _ZNK10QuaZipFile12isSequentialEv@Base 0.4.4 _ZNK10QuaZipFile14bytesAvailableEv@Base 0.4.4 _ZNK10QuaZipFile17getActualFileNameEv@Base 0.4.4 _ZNK10QuaZipFile18getCaseSensitivityEv@Base 0.4.4 _ZNK10QuaZipFile3posEv@Base 0.4.4 _ZNK10QuaZipFile4sizeEv@Base 0.4.4 _ZNK10QuaZipFile5atEndEv@Base 0.4.4 _ZNK10QuaZipFile5csizeEv@Base 0.4.4 _ZNK10QuaZipFile5isRawEv@Base 0.4.4 _ZNK10QuaZipFile5usizeEv@Base 0.4.4 _ZNK10QuaZipFile6getZipEv@Base 0.4.4 _ZNK6QuaZip10getCommentEv@Base 0.4.4 _ZNK6QuaZip10getZipNameEv@Base 0.4.4 _ZNK6QuaZip11getIoDeviceEv@Base 0.4.4 _ZNK6QuaZip11getZipErrorEv@Base 0.4.4 _ZNK6QuaZip14hasCurrentFileEv@Base 0.4.4 _ZNK6QuaZip15getCommentCodecEv@Base 0.4.4 _ZNK6QuaZip15getEntriesCountEv@Base 0.4.4 _ZNK6QuaZip15getFileInfoListEv@Base 0.4.4 _ZNK6QuaZip15getFileNameListEv@Base 0.4.4 _ZNK6QuaZip16getFileNameCodecEv@Base 0.4.4 _ZNK6QuaZip18getCurrentFileInfoEP14QuaZipFileInfo@Base 0.4.4 _ZNK6QuaZip18getCurrentFileNameEv@Base 0.4.4 _ZNK6QuaZip30isDataDescriptorWritingEnabledEv@Base 0.4.4 _ZNK6QuaZip6isOpenEv@Base 0.4.4 _ZNK6QuaZip7getModeEv@Base 0.4.4 _ZTI10QuaAdler32@Base 0.4.4 _ZTI10QuaZipFile@Base 0.4.4 _ZTI13QuaChecksum32@Base 0.4.4 _ZTI8QuaCrc32@Base 0.4.4 _ZTS10QuaAdler32@Base 0.4.4 _ZTS10QuaZipFile@Base 0.4.4 _ZTS13QuaChecksum32@Base 0.4.4 _ZTS8QuaCrc32@Base 0.4.4 _ZTV10QuaAdler32@Base 0.4.4 _ZTV10QuaZipFile@Base 0.4.4 _ZTV13QuaChecksum32@Base 0.4.4 _ZTV8QuaCrc32@Base 0.4.4 fill_qiodevice_filefunc@Base 0.4.4 unzClose@Base 0.4.4 unzCloseCurrentFile@Base 0.4.4 unzGetCurrentFileInfo@Base 0.4.4 unzGetFilePos@Base 0.4.4 unzGetGlobalComment@Base 0.4.4 unzGetGlobalInfo@Base 0.4.4 unzGetLocalExtrafield@Base 0.4.4 unzGetOffset@Base 0.4.4 unzGoToFilePos@Base 0.4.4 unzGoToFirstFile@Base 0.4.4 unzGoToNextFile@Base 0.4.4 unzLocateFile@Base 0.4.4 unzOpen2@Base 0.4.4 unzOpen@Base 0.4.4 unzOpenCurrentFile2@Base 0.4.4 unzOpenCurrentFile3@Base 0.4.4 unzOpenCurrentFile@Base 0.4.4 unzOpenCurrentFilePassword@Base 0.4.4 unzReadCurrentFile@Base 0.4.4 unzSetOffset@Base 0.4.4 unzStringFileNameCompare@Base 0.4.4 unz_copyright@Base 0.4.4 unzeof@Base 0.4.4 unztell@Base 0.4.4 zipClearFlags@Base 0.4.4 zipClose@Base 0.4.4 zipCloseFileInZip@Base 0.4.4 zipCloseFileInZipRaw@Base 0.4.4 zipOpen2@Base 0.4.4 zipOpen@Base 0.4.4 zipOpenNewFileInZip2@Base 0.4.4 zipOpenNewFileInZip3@Base 0.4.4 zipOpenNewFileInZip@Base 0.4.4 zipSetFlags@Base 0.4.4 zipWriteInFileInZip@Base 0.4.4 zip_copyright@Base 0.4.4 quazip-0.9.1/quazip/doc/000077500000000000000000000000001366246114300151165ustar00rootroot00000000000000quazip-0.9.1/quazip/doc/faq.dox000066400000000000000000000043671366246114300164130ustar00rootroot00000000000000/** \page faq QuaZIP FAQ \anchor faq-non-QIODevice Q. Is there any way to use QuaZipFile in Qt where you are supposed to use normal (non-zipped) file, but not through QIODevice API? A. Usually not. For example, if you are passing file name to some database driver (like SQLite), Qt usually just passes this name down to the 3rd-party library, which is usually does not know anything about QIODevice and therefore there is no way to pass QuaZipFile as a normal file. However, if we are talking about some place where you pass file name, and then internally use QFile to open it, then it is a good idea to make an overloaded method, which accepts a QIODevice pointer. Then you would be able to pass QuaZipFile as well as many other nice things such as QBuffer or QProcess. Of course, that's only possible if you have control over the sources of the particular class. \anchor faq-zip64 Q. Can QuaZIP handle files larger than 4GB? What about zip64 standard? A. Starting with version 0.6, QuaZIP uses Minizip 1.1 with zip64 support which should handle large files perfectly. The zip64 support in Minizip looks like it's not 100% conforming to the standard, but 3rd party tools seem to have no problem with the resulting archives. \anchor faq-seekable Q. Can QuaZIP write archives to a sequential QIODevice like QTcpSocket? A. Yes, it's possible since QuaZIP v0.7. It's only possible in mdCreate mode, no mdAppend support. \anchor faq-Minizip-update Q. Can I use another version of Minizip in QuaZIP, not the bundled one? A. No, unfortunately not. To support reading/writing ZIP archives from/to QIODevice objects, some modifications were needed to Minizip. Now that there is a Minizip fork on GitHub, it is theoretically possible to backport these modifications into Minizip in a backward-compatible manner to ensure seamless integration with QuaZIP, but it hasn't been done yet, and there are no short-term plans, only a long-term goal. */ quazip-0.9.1/quazip/doc/index.dox000066400000000000000000000172371366246114300167530ustar00rootroot00000000000000/** \mainpage QuaZIP - Qt/C++ wrapper for Minizip \section overview Overview Minizip, or Gilles Vollant's ZIP/UNZIP package is a simple C library for creating, appending and reading ZIP archives. Qt is a very powerful cross-platform C++ library with a lot of useful modules and classes. With %Qt, you can create rich GUIs, perform networking activities, accessing databases and much much more. If Java is “write once, run everywhere”, %Qt is “write once, compile everywhere” which is not that bad either. One thing %Qt can't do out-of-the-box is write and read ZIP archives. Of course, you can do it with Minizip, but Minizip has its own interface which isn't exactly compatible with %Qt. Namely, in %Qt there is an abstract class called QIODevice, which is Qt-speak for “input/output stream”. There are a lot of classes that accept QIODevice to write some useful things to it—you could serialize XML to a QIODevice, for example. Therefore, wouldn't it be useful if you could open a QIODevice that would write directly to a file in a ZIP archive? Or read from one? That's exactly where QuaZIP comes into the picture. Technically speaking, QuaZIP is a simple C++ wrapper around Minizip. Or you could call it an implementation of the Adapter pattern. With QuaZIP, both ZIP files and files inside ZIP archives can be accessed with QIODevice API. You can even write ZIP files to a sequential devices like TCP sockets, although some limitations apply in this case. \section download Download QuaZIP The latest downloads are available from the GitHub page. Downloads are in source format. The documentation you're reading right now can be build with the “doxygen” tool if you have one installed. Just run it from the project directory and it will create the “doc” directory for you. If you don't have Doxygen installed, you can still read offline docs in the “quazip/doc” subdir and in the header files. Don't confuse those dirs: - “doc” in the project's root is where Doxygen \em output is. - “quazip/doc” is where Doxygen \em input is, along with the header files. Older downloads are available from QuaZIP project's page at SourceForge.net. \section platforms Platforms supported QuaZIP is regularly tested on the following platforms: - linux-g++ (Ubuntu 16.04 LTS, %Qt 5.5.1) - linux-g++ (CentOS 6.9, %Qt 4.6.2) - win32-msvc (MS VS/VC 2013 64-bit, %Qt 5.9.2) It should work fine on any platform supported by %Qt 4.6.2 or later. In theory, older versions might work as well, but aren't guaranteed to. \section whats-new What is new in this version of QuaZIP? See the NEWS.txt file supplied with the distribution. \section Dependencies Just zlib and %Qt 4/5. Sometimes you can get away with using zlib library bundled into %Qt, but usually you need at least its headers. \section building Building, testing and installing \note Instructions given in this section assume that you are using some UNIX dialect, but the build process should be very similar on win32-g++ platform too. On other platforms it's essentially the same process, maybe with some qmake adjustments not specific to QuaZIP itself. To build the library, run: \verbatim $ cd /wherever/quazip/source/is/quazip-x.y.z/quazip $ qmake [PREFIX=where-to-install] $ make \endverbatim Make sure that you have %Qt 4/5 installed with all required headers and utilities (that is, including the 'dev' or 'devel' package on Linux) and that you run qmake utility of the %Qt 4/5, not some other version you may have already installed (you may need to type full path to qmake like /usr/local/qt4/bin/qmake). To reconfigure (with another PREFIX, for example), just run \verbatim qmake distclean \endverbatim and then qmake with the appropriate arguments again. Usually, it is needed to specify additional include path or libraries in qmake args (see qmake reference in the %Qt documentation). For example: \verbatim $ qmake LIBS+=-L/usr/local/zlib/lib INCLUDEPATH+=/usr/local/zlib/include \endverbatim (note abscence of “-I” before the include path and the presence of “-L” before the lib path) Also note that you may or may not need to define ZLIB_WINAPI (qmake DEFINES+=ZLIB_WINAPI) when linking to zlib on Windows, depending on how zlib was built (generally, if using zlibwapi.dll, this define is needed). To install compiled library: \verbatim $ make install \endverbatim By default, QuaZIP compiles as a DLL/SO, but you have other options: - Just copy appropriate source files to your project and use them, but you need to define QUAZIP_STATIC before including any QuaZIP headers (best done as a compiler option). This will save you from possible side effects of importing/exporting QuaZIP symbols. - Compile it as a static library using CONFIG += staticlib qmake option. QUAZIP_STATIC is defined automatically by qmake in this case. Binary compatibility is guaranteed between minor releases starting with version 0.5, thanks to the Pimpl idiom. That is, the next binary incompatible version will be 1.x in the worst case. \section test Testing To check if QuaZIP's basic features work OK on your platform, you may wish to compile the test suite provided in test directory: \verbatim $ cd /wherever/quazip/source/is/quazip-x.y.z/qztest $ qmake $ make $ ./qztest \endverbatim Note that the test suite looks for the quazip library in the “quazip” folder of the project (“../quazip”), but you may wish to use LIBS for some systems (Windows often puts the library in the separate “debug” or “release” directory). If you wish to use the quazip version that's already installed, provide the appropriate path. On some systems you may need to set PATH, LD_LIBRARY_PATH or SHLIB_PATH to get “qztest” to actually run and to use the right version. If everything went fine, the test suite should report a lot of PASS messages. If something goes wrong, it will provide details and a warning that some tests failed. \section using Using See \ref usage “usage page”. \section contacts Authors and contacts This wrapper has been written by Sergei Tachenov. This is my first open source project, and it's pretty old, but it works and many people are happily using it, including myself. If you have anything to say to me about QuaZIP library, feel free to do so (read the \ref faq first, though). I can not promise, though, that I fix all the bugs you report in, add any features you want, or respond to your critics, or respond to your feedback at all. I may be busy, I may be tired of working on QuaZIP, I may be even dead already (you never know...). To report bugs or to post ideas about what should be done, use GitHub. It's an awesome site, where you can report bugs or register yourself an account, fork QuaZIP (don't hesitate to do so), create a new branch, make some changes and issue a pull request, which is GitHub's way of offering patches. See CONTRIBUTING.md file for details. Do not use e-mail to report bugs, please. Reporting bugs and problems with GitHub has that advantage that it is visible to public, and I can always search for open tickets that were created long ago. It is highly unlikely that I will search my mail for that kind of stuff, so if a bug reported by mail isn't fixed immediately, it will likely be forgotten forever. Old bugs may still be available at SourceForge for reference. Copyright (C) 2005-2018 Sergei Tachenov and contributors */ quazip-0.9.1/quazip/doc/usage.dox000066400000000000000000000107141366246114300167410ustar00rootroot00000000000000/** \page usage Usage This page provides general information on QuaZIP usage. See classes QuaZip and QuaZipFile for the detailed documentation on what can QuaZIP do and what it can not. Also, reading comments in the zip.h and unzip.h files (taken from the original ZIP/UNZIP package) is always a good idea too. After all, QuaZIP is just a wrapper with a few convenience extensions and reimplementations. QuaZip is a class representing ZIP archive, QuaZipFile represents a file inside archive and subclasses QIODevice as well. One limitation is that there can be only one instance of QuaZipFile per QuaZip instance, which kind of makes it confusing why there are two classes instead of one. This is actually no more than an API design mistake kept for backwards compatibility. The JlCompress class provides some high-level convenience static methods which may be very useful if all you need is just to “unzip a file” or something like that. \section terminology Terminology “QuaZIP” means the whole library, while “QuaZip” (note the lower case) is just one class in it. “ZIP/UNZIP API” or “Minizip” means the original API of the Gilles Vollant's ZIP/UNZIP package. It was slightly modified to better integrate with Qt. These modifications are not source or binary compatible with the official Minizip release, which means you can't just drop the newer Minizip version into QuaZIP sources and make it work. “ZIP”, “ZIP archive” or “ZIP file” means any ZIP archive. Typically this is a plain file with “.zip” (or “.ZIP”) file name suffix, but it can also be any seekable QIODevice (say, QBuffer, but not QTcpSocket). “A file inside archive”, “a file inside ZIP” or something like that means file either being read or written from/to some ZIP archive. \section general-usage General usage In general, the process looks like this: -# Open or create an archive with a QuaZip instance. -# Open or create a file in the archive with a QuaZipFile instance. -# Perform reading or writing. -# Close the QuaZipFile instance. -# Repeat steps 2–4 for other files if needed. -# Close the QuaZIP instance. See the “qztest” subdirectory for examples. TestQuaZipFile::zipUnzip() is a good place to start. \section error-handling Error handling Almost any call to ZIP/UNZIP API return some error code. Most of the original API's error checking could be done in this wrapper as well, but it would cause unnecessary code bloating without any benefit. So, QuaZIP only checks for situations that ZIP/UNZIP API can not check for. For example, ZIP/UNZIP API has no “ZIP open mode” concept because read and write modes are completely separated. On the other hand, to avoid creating classes like “QuaZipReader”, “QuaZipWriter” or something like that, QuaZIP introduces “ZIP open mode” concept instead, thus making it possible to use one class (QuaZip) for both reading and writing. But this leads to additional open mode checks which are not done in ZIP/UNZIP package. Therefore, error checking is two-level (QuaZIP's level and ZIP/UNZIP API level), which sometimes can be confusing, so here are some advices on how the error checking should be properly done: - Both QuaZip and QuaZipFile have getZipError() function, which return error code of the last ZIP/UNZIP API call. Most function calls reset error code to UNZ_OK on success and set error code on failure. Some functions do not reset error code. Most of them are \c const and do not access ZIP archive in any way. Some, on the other hand, \em do access ZIP archive, but do not reset or set error code. For example, QuaZipFile::pos() function. Such functions are explicitly marked in the documentation. - Most functions have their own way to report errors, by returning a null string, negative value or \c false. If such a function returns error value, call getZipError() to get more information about error. See “zip.h” and “unzip.h” of the ZIP/UNZIP package for error codes. - If the function returns error-stating value (like \c false), but getZipError() returns UNZ_OK, it means that you did something obviously wrong. For example, tried to write in the archive open for reading or not open at all. You better just not do that! Most functions also issue a warning using qWarning() function in such cases. See documentation for a specific function for details on when it should not be called. I know that this is somewhat messy, but I could not find a better way to do all the error handling. */ quazip-0.9.1/quazip/ioapi.h000066400000000000000000000157401366246114300156320ustar00rootroot00000000000000/* ioapi.h -- IO base function header for compress/uncompress .zip part of the MiniZip project - ( http://www.winimage.com/zLibDll/minizip.html ) Copyright (C) 1998-2010 Gilles Vollant (minizip) ( http://www.winimage.com/zLibDll/minizip.html ) Modifications for Zip64 support Copyright (C) 2009-2010 Mathias Svensson ( http://result42.com ) Modified by Sergey A. Tachenov to allow QIODevice API usage. For more info read MiniZip_info.txt Changes Oct-2009 - Defined ZPOS64_T to fpos_t on windows and u_int64_t on linux. (might need to find a better why for this) Oct-2009 - Change to fseeko64, ftello64 and fopen64 so large files would work on linux. More if/def section may be needed to support other platforms Oct-2009 - Defined fxxxx64 calls to normal fopen/ftell/fseek so they would compile on windows. (but you should use iowin32.c for windows instead) */ #ifndef _ZLIBIOAPI64_H #define _ZLIBIOAPI64_H #if (!defined(_WIN32)) && (!defined(WIN32)) // Linux needs this to support file operation on files larger then 4+GB // But might need better if/def to select just the platforms that needs them. #ifndef __USE_FILE_OFFSET64 #define __USE_FILE_OFFSET64 #endif #ifndef __USE_LARGEFILE64 #define __USE_LARGEFILE64 #endif #ifndef _LARGEFILE64_SOURCE #define _LARGEFILE64_SOURCE #endif #ifndef _FILE_OFFSET_BIT #define _FILE_OFFSET_BIT 64 #endif #endif #include #include #include #if defined(USE_FILE32API) #define fopen64 fopen #define ftello64 ftell #define fseeko64 fseek #else #ifdef _MSC_VER #define fopen64 fopen #if (_MSC_VER >= 1400) && (!(defined(NO_MSCVER_FILE64_FUNC))) #define ftello64 _ftelli64 #define fseeko64 _fseeki64 #else // old MSC #define ftello64 ftell #define fseeko64 fseek #endif #endif #endif /* #ifndef ZPOS64_T #ifdef _WIN32 #define ZPOS64_T fpos_t #else #include #define ZPOS64_T uint64_t #endif #endif */ #ifdef HAVE_MINIZIP64_CONF_H #include "mz64conf.h" #endif /* a type choosen by DEFINE */ #ifdef HAVE_64BIT_INT_CUSTOM typedef 64BIT_INT_CUSTOM_TYPE ZPOS64_T; #else #ifdef HAS_STDINT_H #include "stdint.h" typedef uint64_t ZPOS64_T; #else #if defined(_MSC_VER) || defined(__BORLANDC__) typedef unsigned __int64 ZPOS64_T; #else typedef unsigned long long int ZPOS64_T; #endif #endif #endif #ifdef __cplusplus extern "C" { #endif #ifndef OF #define OF _Z_OF #endif #define ZLIB_FILEFUNC_SEEK_CUR (1) #define ZLIB_FILEFUNC_SEEK_END (2) #define ZLIB_FILEFUNC_SEEK_SET (0) #define ZLIB_FILEFUNC_MODE_READ (1) #define ZLIB_FILEFUNC_MODE_WRITE (2) #define ZLIB_FILEFUNC_MODE_READWRITEFILTER (3) #define ZLIB_FILEFUNC_MODE_EXISTING (4) #define ZLIB_FILEFUNC_MODE_CREATE (8) #ifndef ZCALLBACK #if (defined(WIN32) || defined(_WIN32) || defined (WINDOWS) || defined (_WINDOWS)) && defined(CALLBACK) && defined (USEWINDOWS_CALLBACK) #define ZCALLBACK CALLBACK #else #define ZCALLBACK #endif #endif typedef voidpf (ZCALLBACK *open_file_func) OF((voidpf opaque, voidpf file, int mode)); typedef uLong (ZCALLBACK *read_file_func) OF((voidpf opaque, voidpf stream, void* buf, uLong size)); typedef uLong (ZCALLBACK *write_file_func) OF((voidpf opaque, voidpf stream, const void* buf, uLong size)); typedef int (ZCALLBACK *close_file_func) OF((voidpf opaque, voidpf stream)); typedef int (ZCALLBACK *testerror_file_func) OF((voidpf opaque, voidpf stream)); typedef uLong (ZCALLBACK *tell_file_func) OF((voidpf opaque, voidpf stream)); typedef int (ZCALLBACK *seek_file_func) OF((voidpf opaque, voidpf stream, uLong offset, int origin)); /* here is the "old" 32 bits structure structure */ typedef struct zlib_filefunc_def_s { open_file_func zopen_file; read_file_func zread_file; write_file_func zwrite_file; tell_file_func ztell_file; seek_file_func zseek_file; close_file_func zclose_file; testerror_file_func zerror_file; voidpf opaque; } zlib_filefunc_def; typedef ZPOS64_T (ZCALLBACK *tell64_file_func) OF((voidpf opaque, voidpf stream)); typedef int (ZCALLBACK *seek64_file_func) OF((voidpf opaque, voidpf stream, ZPOS64_T offset, int origin)); typedef voidpf (ZCALLBACK *open64_file_func) OF((voidpf opaque, voidpf file, int mode)); typedef struct zlib_filefunc64_def_s { open64_file_func zopen64_file; read_file_func zread_file; write_file_func zwrite_file; tell64_file_func ztell64_file; seek64_file_func zseek64_file; close_file_func zclose_file; testerror_file_func zerror_file; voidpf opaque; close_file_func zfakeclose_file; // for no-auto-close flag } zlib_filefunc64_def; void fill_qiodevice64_filefunc OF((zlib_filefunc64_def* pzlib_filefunc_def)); void fill_qiodevice_filefunc OF((zlib_filefunc_def* pzlib_filefunc_def)); /* now internal definition, only for zip.c and unzip.h */ typedef struct zlib_filefunc64_32_def_s { zlib_filefunc64_def zfile_func64; open_file_func zopen32_file; tell_file_func ztell32_file; seek_file_func zseek32_file; } zlib_filefunc64_32_def; #define ZREAD64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zread_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) #define ZWRITE64(filefunc,filestream,buf,size) ((*((filefunc).zfile_func64.zwrite_file)) ((filefunc).zfile_func64.opaque,filestream,buf,size)) //#define ZTELL64(filefunc,filestream) ((*((filefunc).ztell64_file)) ((filefunc).opaque,filestream)) //#define ZSEEK64(filefunc,filestream,pos,mode) ((*((filefunc).zseek64_file)) ((filefunc).opaque,filestream,pos,mode)) #define ZCLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zclose_file)) ((filefunc).zfile_func64.opaque,filestream)) #define ZFAKECLOSE64(filefunc,filestream) ((*((filefunc).zfile_func64.zfakeclose_file)) ((filefunc).zfile_func64.opaque,filestream)) #define ZERROR64(filefunc,filestream) ((*((filefunc).zfile_func64.zerror_file)) ((filefunc).zfile_func64.opaque,filestream)) voidpf call_zopen64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf file,int mode)); int call_zseek64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin)); ZPOS64_T call_ztell64 OF((const zlib_filefunc64_32_def* pfilefunc,voidpf filestream)); void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32); #define ZOPEN64(filefunc,filename,mode) (call_zopen64((&(filefunc)),(filename),(mode))) #define ZTELL64(filefunc,filestream) (call_ztell64((&(filefunc)),(filestream))) #define ZSEEK64(filefunc,filestream,pos,mode) (call_zseek64((&(filefunc)),(filestream),(pos),(mode))) #ifdef __cplusplus } #endif #endif quazip-0.9.1/quazip/minizip_crypt.h000066400000000000000000000113171366246114300174250ustar00rootroot00000000000000/* crypt.h -- base code for crypt/uncrypt ZIPfile Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant This code is a modified version of crypting code in Infozip distribution The encryption/decryption parts of this source code (as opposed to the non-echoing password parts) were originally written in Europe. The whole source package can be freely distributed, including from the USA. (Prior to January 2000, re-export from the US was a violation of US law.) This encryption code is a direct transcription of the algorithm from Roger Schlafly, described by Phil Katz in the file appnote.txt. This file (appnote.txt) is distributed with the PKZIP program (even in the version without encryption capabilities). If you don't need crypting in your application, just define symbols NOCRYPT and NOUNCRYPT. This code support the "Traditional PKWARE Encryption". The new AES encryption added on Zip format by Winzip (see the page http://www.winzip.com/aes_info.htm ) and PKWare PKZip 5.x Strong Encryption is not supported. */ #include "quazip_global.h" #define CRC32(c, b) ((*(pcrc_32_tab+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8)) /*********************************************************************** * Return the next byte in the pseudo-random sequence */ static int decrypt_byte(unsigned long* pkeys, const z_crc_t FAR * pcrc_32_tab QUAZIP_UNUSED) { //(void) pcrc_32_tab; /* avoid "unused parameter" warning */ unsigned temp; /* POTENTIAL BUG: temp*(temp^1) may overflow in an * unpredictable manner on 16-bit systems; not a problem * with any known compiler so far, though */ temp = ((unsigned)(*(pkeys+2)) & 0xffff) | 2; return (int)(((temp * (temp ^ 1)) >> 8) & 0xff); } /*********************************************************************** * Update the encryption keys with the next byte of plain text */ static int update_keys(unsigned long* pkeys,const z_crc_t FAR * pcrc_32_tab,int c) { (*(pkeys+0)) = CRC32((*(pkeys+0)), c); (*(pkeys+1)) += (*(pkeys+0)) & 0xff; (*(pkeys+1)) = (*(pkeys+1)) * 134775813L + 1; { register int keyshift = (int)((*(pkeys+1)) >> 24); (*(pkeys+2)) = CRC32((*(pkeys+2)), keyshift); } return c; } /*********************************************************************** * Initialize the encryption keys and the random header according to * the given password. */ static void init_keys(const char* passwd,unsigned long* pkeys,const z_crc_t FAR * pcrc_32_tab) { *(pkeys+0) = 305419896L; *(pkeys+1) = 591751049L; *(pkeys+2) = 878082192L; while (*passwd != '\0') { update_keys(pkeys,pcrc_32_tab,(int)*passwd); passwd++; } } #define zdecode(pkeys,pcrc_32_tab,c) \ (update_keys(pkeys,pcrc_32_tab,c ^= decrypt_byte(pkeys,pcrc_32_tab))) #define zencode(pkeys,pcrc_32_tab,c,t) \ (t=decrypt_byte(pkeys,pcrc_32_tab), update_keys(pkeys,pcrc_32_tab,c), t^(c)) #ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED #define RAND_HEAD_LEN 12 /* "last resort" source for second part of crypt seed pattern */ # ifndef ZCR_SEED2 # define ZCR_SEED2 3141592654UL /* use PI as default pattern */ # endif static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) const char *passwd; /* password string */ unsigned char *buf; /* where to write header */ int bufSize; unsigned long* pkeys; const z_crc_t FAR * pcrc_32_tab; unsigned long crcForCrypting; { int n; /* index in random header */ int t; /* temporary */ int c; /* random byte */ unsigned char header[RAND_HEAD_LEN-2]; /* random header */ static unsigned calls = 0; /* ensure different random header each time */ if (bufSize> 7) & 0xff; header[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, c, t); } /* Encrypt random header (last two bytes is high word of crc) */ init_keys(passwd, pkeys, pcrc_32_tab); for (n = 0; n < RAND_HEAD_LEN-2; n++) { buf[n] = (unsigned char)zencode(pkeys, pcrc_32_tab, header[n], t); } buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 16) & 0xff, t); buf[n++] = zencode(pkeys, pcrc_32_tab, (int)(crcForCrypting >> 24) & 0xff, t); return n; } #endif quazip-0.9.1/quazip/qioapi.cpp000066400000000000000000000256511366246114300163500ustar00rootroot00000000000000/* ioapi.c -- IO base function header for compress/uncompress .zip files using zlib + zip or unzip API Version 1.01e, February 12th, 2005 Copyright (C) 1998-2005 Gilles Vollant Modified by Sergey A. Tachenov to integrate with Qt. */ #include #include #include #include #include "ioapi.h" #include "quazip_global.h" #include #if (QT_VERSION >= 0x050100) #define QUAZIP_QSAVEFILE_BUG_WORKAROUND #endif #ifdef QUAZIP_QSAVEFILE_BUG_WORKAROUND #include #endif /* I've found an old Unix (a SunOS 4.1.3_U1) without all SEEK_* defined.... */ #ifndef SEEK_CUR #define SEEK_CUR 1 #endif #ifndef SEEK_END #define SEEK_END 2 #endif #ifndef SEEK_SET #define SEEK_SET 0 #endif voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,voidpf file,int mode) { if (pfilefunc->zfile_func64.zopen64_file != NULL) return (*(pfilefunc->zfile_func64.zopen64_file)) (pfilefunc->zfile_func64.opaque,file,mode); else { return (*(pfilefunc->zopen32_file))(pfilefunc->zfile_func64.opaque,file,mode); } } int call_zseek64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream, ZPOS64_T offset, int origin) { if (pfilefunc->zfile_func64.zseek64_file != NULL) return (*(pfilefunc->zfile_func64.zseek64_file)) (pfilefunc->zfile_func64.opaque,filestream,offset,origin); else { uLong offsetTruncated = (uLong)offset; if (offsetTruncated != offset) return -1; else return (*(pfilefunc->zseek32_file))(pfilefunc->zfile_func64.opaque,filestream,offsetTruncated,origin); } } ZPOS64_T call_ztell64 (const zlib_filefunc64_32_def* pfilefunc,voidpf filestream) { if (pfilefunc->zfile_func64.zseek64_file != NULL) return (*(pfilefunc->zfile_func64.ztell64_file)) (pfilefunc->zfile_func64.opaque,filestream); else { uLong tell_uLong = (*(pfilefunc->ztell32_file))(pfilefunc->zfile_func64.opaque,filestream); if ((tell_uLong) == ((uLong)-1)) return (ZPOS64_T)-1; else return tell_uLong; } } /// @cond internal struct QIODevice_descriptor { // Position only used for writing to sequential devices. qint64 pos; inline QIODevice_descriptor(): pos(0) {} }; /// @endcond voidpf ZCALLBACK qiodevice_open_file_func ( voidpf opaque, voidpf file, int mode) { QIODevice_descriptor *d = reinterpret_cast(opaque); QIODevice *iodevice = reinterpret_cast(file); QIODevice::OpenMode desiredMode; if ((mode & ZLIB_FILEFUNC_MODE_READWRITEFILTER)==ZLIB_FILEFUNC_MODE_READ) desiredMode = QIODevice::ReadOnly; else if (mode & ZLIB_FILEFUNC_MODE_EXISTING) desiredMode = QIODevice::ReadWrite; else if (mode & ZLIB_FILEFUNC_MODE_CREATE) desiredMode = QIODevice::WriteOnly; if (iodevice->isOpen()) { if ((iodevice->openMode() & desiredMode) == desiredMode) { if (desiredMode != QIODevice::WriteOnly && iodevice->isSequential()) { // We can use sequential devices only for writing. delete d; return NULL; } else { if ((desiredMode & QIODevice::WriteOnly) != 0) { // open for writing, need to seek existing device if (!iodevice->isSequential()) { iodevice->seek(0); } else { d->pos = iodevice->pos(); } } } return iodevice; } else { delete d; return NULL; } } iodevice->open(desiredMode); if (iodevice->isOpen()) { if (desiredMode != QIODevice::WriteOnly && iodevice->isSequential()) { // We can use sequential devices only for writing. iodevice->close(); delete d; return NULL; } else { return iodevice; } } else { delete d; return NULL; } } uLong ZCALLBACK qiodevice_read_file_func ( voidpf opaque, voidpf stream, void* buf, uLong size) { QIODevice_descriptor *d = reinterpret_cast(opaque); QIODevice *iodevice = reinterpret_cast(stream); qint64 ret64 = iodevice->read((char*)buf,size); uLong ret; ret = (uLong) ret64; if (ret64 != -1) { d->pos += ret64; } return ret; } uLong ZCALLBACK qiodevice_write_file_func ( voidpf opaque, voidpf stream, const void* buf, uLong size) { QIODevice_descriptor *d = reinterpret_cast(opaque); QIODevice *iodevice = reinterpret_cast(stream); uLong ret; qint64 ret64 = iodevice->write((char*)buf,size); if (ret64 != -1) { d->pos += ret64; } ret = (uLong) ret64; return ret; } uLong ZCALLBACK qiodevice_tell_file_func ( voidpf opaque, voidpf stream) { QIODevice_descriptor *d = reinterpret_cast(opaque); QIODevice *iodevice = reinterpret_cast(stream); uLong ret; qint64 ret64; if (iodevice->isSequential()) { ret64 = d->pos; } else { ret64 = iodevice->pos(); } ret = static_cast(ret64); return ret; } ZPOS64_T ZCALLBACK qiodevice64_tell_file_func ( voidpf opaque, voidpf stream) { QIODevice_descriptor *d = reinterpret_cast(opaque); QIODevice *iodevice = reinterpret_cast(stream); qint64 ret; if (iodevice->isSequential()) { ret = d->pos; } else { ret = iodevice->pos(); } return static_cast(ret); } int ZCALLBACK qiodevice_seek_file_func ( voidpf /*opaque UNUSED*/, voidpf stream, uLong offset, int origin) { QIODevice *iodevice = reinterpret_cast(stream); if (iodevice->isSequential()) { if (origin == ZLIB_FILEFUNC_SEEK_END && offset == 0) { // sequential devices are always at end (needed in mdAppend) return 0; } else { qWarning("qiodevice_seek_file_func() called for sequential device"); return -1; } } uLong qiodevice_seek_result=0; int ret; switch (origin) { case ZLIB_FILEFUNC_SEEK_CUR : qiodevice_seek_result = ((QIODevice*)stream)->pos() + offset; break; case ZLIB_FILEFUNC_SEEK_END : qiodevice_seek_result = ((QIODevice*)stream)->size() - offset; break; case ZLIB_FILEFUNC_SEEK_SET : qiodevice_seek_result = offset; break; default: return -1; } ret = !iodevice->seek(qiodevice_seek_result); return ret; } int ZCALLBACK qiodevice64_seek_file_func ( voidpf /*opaque UNUSED*/, voidpf stream, ZPOS64_T offset, int origin) { QIODevice *iodevice = reinterpret_cast(stream); if (iodevice->isSequential()) { if (origin == ZLIB_FILEFUNC_SEEK_END && offset == 0) { // sequential devices are always at end (needed in mdAppend) return 0; } else { qWarning("qiodevice_seek_file_func() called for sequential device"); return -1; } } qint64 qiodevice_seek_result=0; int ret; switch (origin) { case ZLIB_FILEFUNC_SEEK_CUR : qiodevice_seek_result = ((QIODevice*)stream)->pos() + offset; break; case ZLIB_FILEFUNC_SEEK_END : qiodevice_seek_result = ((QIODevice*)stream)->size() - offset; break; case ZLIB_FILEFUNC_SEEK_SET : qiodevice_seek_result = offset; break; default: return -1; } ret = !iodevice->seek(qiodevice_seek_result); return ret; } int ZCALLBACK qiodevice_close_file_func ( voidpf opaque, voidpf stream) { QIODevice_descriptor *d = reinterpret_cast(opaque); delete d; QIODevice *device = reinterpret_cast(stream); #ifdef QUAZIP_QSAVEFILE_BUG_WORKAROUND // QSaveFile terribly breaks the is-a idiom: // it IS a QIODevice, but it is NOT compatible with it: close() is private QSaveFile *file = qobject_cast(device); if (file != NULL) { // We have to call the ugly commit() instead: return file->commit() ? 0 : -1; } #endif device->close(); return 0; } int ZCALLBACK qiodevice_fakeclose_file_func ( voidpf opaque, voidpf /*stream*/) { QIODevice_descriptor *d = reinterpret_cast(opaque); delete d; return 0; } int ZCALLBACK qiodevice_error_file_func ( voidpf /*opaque UNUSED*/, voidpf /*stream UNUSED*/) { // can't check for error due to the QIODevice API limitation return 0; } void fill_qiodevice_filefunc ( zlib_filefunc_def* pzlib_filefunc_def) { pzlib_filefunc_def->zopen_file = qiodevice_open_file_func; pzlib_filefunc_def->zread_file = qiodevice_read_file_func; pzlib_filefunc_def->zwrite_file = qiodevice_write_file_func; pzlib_filefunc_def->ztell_file = qiodevice_tell_file_func; pzlib_filefunc_def->zseek_file = qiodevice_seek_file_func; pzlib_filefunc_def->zclose_file = qiodevice_close_file_func; pzlib_filefunc_def->zerror_file = qiodevice_error_file_func; pzlib_filefunc_def->opaque = new QIODevice_descriptor; } void fill_qiodevice64_filefunc ( zlib_filefunc64_def* pzlib_filefunc_def) { // Open functions are the same for Qt. pzlib_filefunc_def->zopen64_file = qiodevice_open_file_func; pzlib_filefunc_def->zread_file = qiodevice_read_file_func; pzlib_filefunc_def->zwrite_file = qiodevice_write_file_func; pzlib_filefunc_def->ztell64_file = qiodevice64_tell_file_func; pzlib_filefunc_def->zseek64_file = qiodevice64_seek_file_func; pzlib_filefunc_def->zclose_file = qiodevice_close_file_func; pzlib_filefunc_def->zerror_file = qiodevice_error_file_func; pzlib_filefunc_def->opaque = new QIODevice_descriptor; pzlib_filefunc_def->zfakeclose_file = qiodevice_fakeclose_file_func; } void fill_zlib_filefunc64_32_def_from_filefunc32(zlib_filefunc64_32_def* p_filefunc64_32,const zlib_filefunc_def* p_filefunc32) { p_filefunc64_32->zfile_func64.zopen64_file = NULL; p_filefunc64_32->zopen32_file = p_filefunc32->zopen_file; p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; p_filefunc64_32->zfile_func64.zread_file = p_filefunc32->zread_file; p_filefunc64_32->zfile_func64.zwrite_file = p_filefunc32->zwrite_file; p_filefunc64_32->zfile_func64.ztell64_file = NULL; p_filefunc64_32->zfile_func64.zseek64_file = NULL; p_filefunc64_32->zfile_func64.zclose_file = p_filefunc32->zclose_file; p_filefunc64_32->zfile_func64.zerror_file = p_filefunc32->zerror_file; p_filefunc64_32->zfile_func64.opaque = p_filefunc32->opaque; p_filefunc64_32->zfile_func64.zfakeclose_file = NULL; p_filefunc64_32->zseek32_file = p_filefunc32->zseek_file; p_filefunc64_32->ztell32_file = p_filefunc32->ztell_file; } quazip-0.9.1/quazip/quaadler32.cpp000066400000000000000000000025471366246114300170300ustar00rootroot00000000000000/* Copyright (C) 2010 Adam Walczak Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include "quaadler32.h" #include QuaAdler32::QuaAdler32() { reset(); } quint32 QuaAdler32::calculate(const QByteArray &data) { return adler32( adler32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() ); } void QuaAdler32::reset() { checksum = adler32(0L, Z_NULL, 0); } void QuaAdler32::update(const QByteArray &buf) { checksum = adler32( checksum, (const Bytef*)buf.data(), buf.size() ); } quint32 QuaAdler32::value() { return checksum; } quazip-0.9.1/quazip/quaadler32.h000066400000000000000000000026721366246114300164740ustar00rootroot00000000000000#ifndef QUAADLER32_H #define QUAADLER32_H /* Copyright (C) 2010 Adam Walczak Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include #include "quachecksum32.h" /// Adler32 checksum /** \class QuaAdler32 quaadler32.h * This class wrappers the adler32 function with the QuaChecksum32 interface. * See QuaChecksum32 for more info. */ class QUAZIP_EXPORT QuaAdler32 : public QuaChecksum32 { public: QuaAdler32(); quint32 calculate(const QByteArray &data); void reset(); void update(const QByteArray &buf); quint32 value(); private: quint32 checksum; }; #endif //QUAADLER32_H quazip-0.9.1/quazip/quachecksum32.h000066400000000000000000000043651366246114300172100ustar00rootroot00000000000000#ifndef QUACHECKSUM32_H #define QUACHECKSUM32_H /* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include #include "quazip_global.h" /// Checksum interface. /** \class QuaChecksum32 quachecksum32.h * This is an interface for 32 bit checksums. * Classes implementing this interface can calcunate a certin * checksum in a single step: * \code * QChecksum32 *crc32 = new QuaCrc32(); * rasoult = crc32->calculate(data); * \endcode * or by streaming the data: * \code * QChecksum32 *crc32 = new QuaCrc32(); * while(!fileA.atEnd()) * crc32->update(fileA.read(bufSize)); * resoultA = crc32->value(); * crc32->reset(); * while(!fileB.atEnd()) * crc32->update(fileB.read(bufSize)); * resoultB = crc32->value(); * \endcode */ class QUAZIP_EXPORT QuaChecksum32 { public: ///Calculates the checksum for data. /** \a data source data * \return data checksum * * This function has no efect on the value returned by value(). */ virtual quint32 calculate(const QByteArray &data) = 0; ///Resets the calculation on a checksun for a stream. virtual void reset() = 0; ///Updates the calculated checksum for the stream /** \a buf next portion of data from the stream */ virtual void update(const QByteArray &buf) = 0; ///Value of the checksum calculated for the stream passed throw update(). /** \return checksum */ virtual quint32 value() = 0; }; #endif //QUACHECKSUM32_H quazip-0.9.1/quazip/quacrc32.cpp000066400000000000000000000024611366246114300165030ustar00rootroot00000000000000/* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include "quacrc32.h" #include QuaCrc32::QuaCrc32() { reset(); } quint32 QuaCrc32::calculate(const QByteArray &data) { return crc32( crc32(0L, Z_NULL, 0), (const Bytef*)data.data(), data.size() ); } void QuaCrc32::reset() { checksum = crc32(0L, Z_NULL, 0); } void QuaCrc32::update(const QByteArray &buf) { checksum = crc32( checksum, (const Bytef*)buf.data(), buf.size() ); } quint32 QuaCrc32::value() { return checksum; } quazip-0.9.1/quazip/quacrc32.h000066400000000000000000000025441366246114300161520ustar00rootroot00000000000000#ifndef QUACRC32_H #define QUACRC32_H /* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include "quachecksum32.h" ///CRC32 checksum /** \class QuaCrc32 quacrc32.h * This class wrappers the crc32 function with the QuaChecksum32 interface. * See QuaChecksum32 for more info. */ class QUAZIP_EXPORT QuaCrc32 : public QuaChecksum32 { public: QuaCrc32(); quint32 calculate(const QByteArray &data); void reset(); void update(const QByteArray &buf); quint32 value(); private: quint32 checksum; }; #endif //QUACRC32_H quazip-0.9.1/quazip/quagzipfile.cpp000066400000000000000000000103151366246114300173750ustar00rootroot00000000000000/* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include #include "quagzipfile.h" /// \cond internal class QuaGzipFilePrivate { friend class QuaGzipFile; QString fileName; gzFile gzd; inline QuaGzipFilePrivate(): gzd(NULL) {} inline QuaGzipFilePrivate(const QString &fileName): fileName(fileName), gzd(NULL) {} template bool open(FileId id, QIODevice::OpenMode mode, QString &error); gzFile open(int fd, const char *modeString); gzFile open(const QString &name, const char *modeString); }; gzFile QuaGzipFilePrivate::open(const QString &name, const char *modeString) { return gzopen(QFile::encodeName(name).constData(), modeString); } gzFile QuaGzipFilePrivate::open(int fd, const char *modeString) { return gzdopen(fd, modeString); } template bool QuaGzipFilePrivate::open(FileId id, QIODevice::OpenMode mode, QString &error) { char modeString[2]; modeString[0] = modeString[1] = '\0'; if ((mode & QIODevice::Append) != 0) { error = QuaGzipFile::tr("QIODevice::Append is not " "supported for GZIP"); return false; } if ((mode & QIODevice::ReadOnly) != 0 && (mode & QIODevice::WriteOnly) != 0) { error = QuaGzipFile::tr("Opening gzip for both reading" " and writing is not supported"); return false; } else if ((mode & QIODevice::ReadOnly) != 0) { modeString[0] = 'r'; } else if ((mode & QIODevice::WriteOnly) != 0) { modeString[0] = 'w'; } else { error = QuaGzipFile::tr("You can open a gzip either for reading" " or for writing. Which is it?"); return false; } gzd = open(id, modeString); if (gzd == NULL) { error = QuaGzipFile::tr("Could not gzopen() file"); return false; } return true; } /// \endcond QuaGzipFile::QuaGzipFile(): d(new QuaGzipFilePrivate()) { } QuaGzipFile::QuaGzipFile(QObject *parent): QIODevice(parent), d(new QuaGzipFilePrivate()) { } QuaGzipFile::QuaGzipFile(const QString &fileName, QObject *parent): QIODevice(parent), d(new QuaGzipFilePrivate(fileName)) { } QuaGzipFile::~QuaGzipFile() { if (isOpen()) { close(); } delete d; } void QuaGzipFile::setFileName(const QString& fileName) { d->fileName = fileName; } QString QuaGzipFile::getFileName() const { return d->fileName; } bool QuaGzipFile::isSequential() const { return true; } bool QuaGzipFile::open(QIODevice::OpenMode mode) { QString error; if (!d->open(d->fileName, mode, error)) { setErrorString(error); return false; } return QIODevice::open(mode); } bool QuaGzipFile::open(int fd, QIODevice::OpenMode mode) { QString error; if (!d->open(fd, mode, error)) { setErrorString(error); return false; } return QIODevice::open(mode); } bool QuaGzipFile::flush() { return gzflush(d->gzd, Z_SYNC_FLUSH) == Z_OK; } void QuaGzipFile::close() { QIODevice::close(); gzclose(d->gzd); } qint64 QuaGzipFile::readData(char *data, qint64 maxSize) { return gzread(d->gzd, (voidp)data, (unsigned)maxSize); } qint64 QuaGzipFile::writeData(const char *data, qint64 maxSize) { if (maxSize == 0) return 0; int written = gzwrite(d->gzd, (voidp)data, (unsigned)maxSize); if (written == 0) return -1; else return written; } quazip-0.9.1/quazip/quagzipfile.h000066400000000000000000000071521366246114300170470ustar00rootroot00000000000000#ifndef QUAZIP_QUAGZIPFILE_H #define QUAZIP_QUAGZIPFILE_H /* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include #include "quazip_global.h" #include class QuaGzipFilePrivate; /// GZIP file /** This class is a wrapper around GZIP file access functions in zlib. Unlike QuaZip classes, it doesn't allow reading from a GZIP file opened as QIODevice, for example, if your GZIP file is in QBuffer. It only provides QIODevice access to a GZIP file contents, but the GZIP file itself must be identified by its name on disk or by descriptor id. */ class QUAZIP_EXPORT QuaGzipFile: public QIODevice { Q_OBJECT public: /// Empty constructor. /** Must call setFileName() before trying to open. */ QuaGzipFile(); /// Empty constructor with a parent. /** Must call setFileName() before trying to open. \param parent The parent object, as per QObject logic. */ QuaGzipFile(QObject *parent); /// Constructor. /** \param fileName The name of the GZIP file. \param parent The parent object, as per QObject logic. */ QuaGzipFile(const QString &fileName, QObject *parent = NULL); /// Destructor. virtual ~QuaGzipFile(); /// Sets the name of the GZIP file to be opened. void setFileName(const QString& fileName); /// Returns the name of the GZIP file. QString getFileName() const; /// Returns true. /** Strictly speaking, zlib supports seeking for GZIP files, but it is poorly implemented, because there is no way to implement it properly. For reading, seeking backwards is very slow, and for writing, it is downright impossible. Therefore, QuaGzipFile does not support seeking at all. */ virtual bool isSequential() const; /// Opens the file. /** \param mode Can be either QIODevice::Write or QIODevice::Read. ReadWrite and Append aren't supported. */ virtual bool open(QIODevice::OpenMode mode); /// Opens the file. /** \overload \param fd The file descriptor to read/write the GZIP file from/to. \param mode Can be either QIODevice::Write or QIODevice::Read. ReadWrite and Append aren't supported. */ virtual bool open(int fd, QIODevice::OpenMode mode); /// Flushes data to file. /** The data is written using Z_SYNC_FLUSH mode. Doesn't make any sense when reading. */ virtual bool flush(); /// Closes the file. virtual void close(); protected: /// Implementation of QIODevice::readData(). virtual qint64 readData(char *data, qint64 maxSize); /// Implementation of QIODevice::writeData(). virtual qint64 writeData(const char *data, qint64 maxSize); private: // not implemented by design to disable copy QuaGzipFile(const QuaGzipFile &that); QuaGzipFile& operator=(const QuaGzipFile &that); QuaGzipFilePrivate *d; }; #endif // QUAZIP_QUAGZIPFILE_H quazip-0.9.1/quazip/quaziodevice.cpp000066400000000000000000000225031366246114300175470ustar00rootroot00000000000000/* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include "quaziodevice.h" #define QUAZIO_INBUFSIZE 4096 #define QUAZIO_OUTBUFSIZE 4096 /// \cond internal class QuaZIODevicePrivate { friend class QuaZIODevice; QuaZIODevicePrivate(QIODevice *io, QuaZIODevice *q); ~QuaZIODevicePrivate(); QIODevice *io; QuaZIODevice *q; z_stream zins; z_stream zouts; char *inBuf; int inBufPos; int inBufSize; char *outBuf; int outBufPos; int outBufSize; bool zBufError; bool atEnd; bool flush(int sync); int doFlush(QString &error); }; QuaZIODevicePrivate::QuaZIODevicePrivate(QIODevice *io, QuaZIODevice *q): io(io), q(q), inBuf(NULL), inBufPos(0), inBufSize(0), outBuf(NULL), outBufPos(0), outBufSize(0), zBufError(false), atEnd(false) { zins.zalloc = (alloc_func) NULL; zins.zfree = (free_func) NULL; zins.opaque = NULL; zouts.zalloc = (alloc_func) NULL; zouts.zfree = (free_func) NULL; zouts.opaque = NULL; inBuf = new char[QUAZIO_INBUFSIZE]; outBuf = new char[QUAZIO_OUTBUFSIZE]; #ifdef QUAZIP_ZIODEVICE_DEBUG_OUTPUT debug.setFileName("debug.out"); debug.open(QIODevice::WriteOnly); #endif #ifdef QUAZIP_ZIODEVICE_DEBUG_INPUT indebug.setFileName("debug.in"); indebug.open(QIODevice::WriteOnly); #endif } QuaZIODevicePrivate::~QuaZIODevicePrivate() { #ifdef QUAZIP_ZIODEVICE_DEBUG_OUTPUT debug.close(); #endif #ifdef QUAZIP_ZIODEVICE_DEBUG_INPUT indebug.close(); #endif if (inBuf != NULL) delete[] inBuf; if (outBuf != NULL) delete[] outBuf; } bool QuaZIODevicePrivate::flush(int sync) { QString error; if (doFlush(error) < 0) { q->setErrorString(error); return false; } // can't flush buffer, some data is still waiting if (outBufPos < outBufSize) return true; Bytef c = 0; zouts.next_in = &c; // fake input buffer zouts.avail_in = 0; // of zero size do { zouts.next_out = (Bytef *) outBuf; zouts.avail_out = QUAZIO_OUTBUFSIZE; int result = deflate(&zouts, sync); switch (result) { case Z_OK: case Z_STREAM_END: outBufSize = (char *) zouts.next_out - outBuf; if (doFlush(error) < 0) { q->setErrorString(error); return false; } if (outBufPos < outBufSize) return true; break; case Z_BUF_ERROR: // nothing to write? return true; default: q->setErrorString(QString::fromLocal8Bit(zouts.msg)); return false; } } while (zouts.avail_out == 0); return true; } int QuaZIODevicePrivate::doFlush(QString &error) { int flushed = 0; while (outBufPos < outBufSize) { int more = io->write(outBuf + outBufPos, outBufSize - outBufPos); if (more == -1) { error = io->errorString(); return -1; } if (more == 0) break; outBufPos += more; flushed += more; } if (outBufPos == outBufSize) { outBufPos = outBufSize = 0; } return flushed; } /// \endcond // #define QUAZIP_ZIODEVICE_DEBUG_OUTPUT // #define QUAZIP_ZIODEVICE_DEBUG_INPUT #ifdef QUAZIP_ZIODEVICE_DEBUG_OUTPUT #include static QFile debug; #endif #ifdef QUAZIP_ZIODEVICE_DEBUG_INPUT #include static QFile indebug; #endif QuaZIODevice::QuaZIODevice(QIODevice *io, QObject *parent): QIODevice(parent), d(new QuaZIODevicePrivate(io, this)) { connect(io, SIGNAL(readyRead()), SIGNAL(readyRead())); } QuaZIODevice::~QuaZIODevice() { if (isOpen()) close(); delete d; } QIODevice *QuaZIODevice::getIoDevice() const { return d->io; } bool QuaZIODevice::open(QIODevice::OpenMode mode) { if ((mode & QIODevice::Append) != 0) { setErrorString(tr("QIODevice::Append is not supported for" " QuaZIODevice")); return false; } if ((mode & QIODevice::ReadWrite) == QIODevice::ReadWrite) { setErrorString(tr("QIODevice::ReadWrite is not supported for" " QuaZIODevice")); return false; } if ((mode & QIODevice::ReadOnly) != 0) { if (inflateInit(&d->zins) != Z_OK) { setErrorString(QString::fromLocal8Bit(d->zins.msg)); return false; } } if ((mode & QIODevice::WriteOnly) != 0) { if (deflateInit(&d->zouts, Z_DEFAULT_COMPRESSION) != Z_OK) { setErrorString(QString::fromLocal8Bit(d->zouts.msg)); return false; } } return QIODevice::open(mode); } void QuaZIODevice::close() { if ((openMode() & QIODevice::ReadOnly) != 0) { if (inflateEnd(&d->zins) != Z_OK) { setErrorString(QString::fromLocal8Bit(d->zins.msg)); } } if ((openMode() & QIODevice::WriteOnly) != 0) { d->flush(Z_FINISH); if (deflateEnd(&d->zouts) != Z_OK) { setErrorString(QString::fromLocal8Bit(d->zouts.msg)); } } QIODevice::close(); } qint64 QuaZIODevice::readData(char *data, qint64 maxSize) { int read = 0; while (read < maxSize) { if (d->inBufPos == d->inBufSize) { d->inBufPos = 0; d->inBufSize = d->io->read(d->inBuf, QUAZIO_INBUFSIZE); if (d->inBufSize == -1) { d->inBufSize = 0; setErrorString(d->io->errorString()); return -1; } if (d->inBufSize == 0) break; } while (read < maxSize && d->inBufPos < d->inBufSize) { d->zins.next_in = (Bytef *) (d->inBuf + d->inBufPos); d->zins.avail_in = d->inBufSize - d->inBufPos; d->zins.next_out = (Bytef *) (data + read); d->zins.avail_out = (uInt) (maxSize - read); // hope it's less than 2GB int more = 0; switch (inflate(&d->zins, Z_SYNC_FLUSH)) { case Z_OK: read = (char *) d->zins.next_out - data; d->inBufPos = (char *) d->zins.next_in - d->inBuf; break; case Z_STREAM_END: read = (char *) d->zins.next_out - data; d->inBufPos = (char *) d->zins.next_in - d->inBuf; d->atEnd = true; return read; case Z_BUF_ERROR: // this should never happen, but just in case if (!d->zBufError) { qWarning("Z_BUF_ERROR detected with %d/%d in/out, weird", d->zins.avail_in, d->zins.avail_out); d->zBufError = true; } memmove(d->inBuf, d->inBuf + d->inBufPos, d->inBufSize - d->inBufPos); d->inBufSize -= d->inBufPos; d->inBufPos = 0; more = d->io->read(d->inBuf + d->inBufSize, QUAZIO_INBUFSIZE - d->inBufSize); if (more == -1) { setErrorString(d->io->errorString()); return -1; } if (more == 0) return read; d->inBufSize += more; break; default: setErrorString(QString::fromLocal8Bit(d->zins.msg)); return -1; } } } #ifdef QUAZIP_ZIODEVICE_DEBUG_INPUT indebug.write(data, read); #endif return read; } qint64 QuaZIODevice::writeData(const char *data, qint64 maxSize) { int written = 0; QString error; if (d->doFlush(error) == -1) { setErrorString(error); return -1; } while (written < maxSize) { // there is some data waiting in the output buffer if (d->outBufPos < d->outBufSize) return written; d->zouts.next_in = (Bytef *) (data + written); d->zouts.avail_in = (uInt) (maxSize - written); // hope it's less than 2GB d->zouts.next_out = (Bytef *) d->outBuf; d->zouts.avail_out = QUAZIO_OUTBUFSIZE; switch (deflate(&d->zouts, Z_NO_FLUSH)) { case Z_OK: written = (char *) d->zouts.next_in - data; d->outBufSize = (char *) d->zouts.next_out - d->outBuf; break; default: setErrorString(QString::fromLocal8Bit(d->zouts.msg)); return -1; } if (d->doFlush(error) == -1) { setErrorString(error); return -1; } } #ifdef QUAZIP_ZIODEVICE_DEBUG_OUTPUT debug.write(data, written); #endif return written; } bool QuaZIODevice::flush() { return d->flush(Z_SYNC_FLUSH); } bool QuaZIODevice::isSequential() const { return true; } bool QuaZIODevice::atEnd() const { // Here we MUST check QIODevice::bytesAvailable() because WE // might have reached the end, but QIODevice didn't-- // it could have simply pre-buffered all remaining data. return (openMode() == NotOpen) || (QIODevice::bytesAvailable() == 0 && d->atEnd); } qint64 QuaZIODevice::bytesAvailable() const { // If we haven't recevied Z_STREAM_END, it means that // we have at least one more input byte available. // Plus whatever QIODevice has buffered. return (d->atEnd ? 0 : 1) + QIODevice::bytesAvailable(); } quazip-0.9.1/quazip/quaziodevice.h000066400000000000000000000066071366246114300172230ustar00rootroot00000000000000#ifndef QUAZIP_QUAZIODEVICE_H #define QUAZIP_QUAZIODEVICE_H /* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include #include "quazip_global.h" #include class QuaZIODevicePrivate; /// A class to compress/decompress QIODevice. /** This class can be used to compress any data written to QIODevice or decompress it back. Compressing data sent over a QTcpSocket is a good example. */ class QUAZIP_EXPORT QuaZIODevice: public QIODevice { friend class QuaZIODevicePrivate; Q_OBJECT public: /// Constructor. /** \param io The QIODevice to read/write. \param parent The parent object, as per QObject logic. */ QuaZIODevice(QIODevice *io, QObject *parent = NULL); /// Destructor. ~QuaZIODevice(); /// Flushes data waiting to be written. /** Unfortunately, as QIODevice doesn't support flush() by itself, the only thing this method does is write the compressed data into the device using Z_SYNC_FLUSH mode. If you need the compressed data to actually be flushed from the buffer of the underlying QIODevice, you need to call its flush() method as well, providing it supports it (like QTcpSocket does). Example: \code QuaZIODevice dev(&sock); dev.open(QIODevice::Write); dev.write(yourDataGoesHere); dev.flush(); sock->flush(); // this actually sends data to network \endcode This may change in the future versions of QuaZIP by implementing an ugly hack: trying to cast the QIODevice using qobject_cast to known flush()-supporting subclasses, and calling flush if the resulting pointer is not zero. */ virtual bool flush(); /// Opens the device. /** \param mode Neither QIODevice::ReadWrite nor QIODevice::Append are not supported. */ virtual bool open(QIODevice::OpenMode mode); /// Closes this device, but not the underlying one. /** The underlying QIODevice is not closed in case you want to write something else to it. */ virtual void close(); /// Returns the underlying device. QIODevice *getIoDevice() const; /// Returns true. virtual bool isSequential() const; /// Returns true iff the end of the compressed stream is reached. virtual bool atEnd() const; /// Returns the number of the bytes buffered. virtual qint64 bytesAvailable() const; protected: /// Implementation of QIODevice::readData(). virtual qint64 readData(char *data, qint64 maxSize); /// Implementation of QIODevice::writeData(). virtual qint64 writeData(const char *data, qint64 maxSize); private: QuaZIODevicePrivate *d; }; #endif // QUAZIP_QUAZIODEVICE_H quazip-0.9.1/quazip/quazip.cpp000066400000000000000000000551371366246114300164010ustar00rootroot00000000000000/* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant, see quazip/(un)zip.h files for details, basically it's zlib license. **/ #include #include #include #include "quazip.h" #define QUAZIP_OS_UNIX 3u /// All the internal stuff for the QuaZip class. /** \internal This class keeps all the private stuff for the QuaZip class so it can be changed without breaking binary compatibility, according to the Pimpl idiom. */ class QuaZipPrivate { friend class QuaZip; private: Q_DISABLE_COPY(QuaZipPrivate) /// The pointer to the corresponding QuaZip instance. QuaZip *q; /// The codec for file names (used when UTF-8 is not enabled). QTextCodec *fileNameCodec; /// The codec for comments (used when UTF-8 is not enabled). QTextCodec *commentCodec; /// The archive file name. QString zipName; /// The device to access the archive. QIODevice *ioDevice; /// The global comment. QString comment; /// The open mode. QuaZip::Mode mode; union { /// The internal handle for UNZIP modes. unzFile unzFile_f; /// The internal handle for ZIP modes. zipFile zipFile_f; }; /// Whether a current file is set. bool hasCurrentFile_f; /// The last error. int zipError; /// Whether \ref QuaZip::setDataDescriptorWritingEnabled() "the data descriptor writing mode" is enabled. bool dataDescriptorWritingEnabled; /// The zip64 mode. bool zip64; /// The auto-close flag. bool autoClose; /// The UTF-8 flag. bool utf8; /// The OS code. uint osCode; inline QTextCodec *getDefaultFileNameCodec() { if (defaultFileNameCodec == NULL) { return QTextCodec::codecForLocale(); } else { return defaultFileNameCodec; } } /// The constructor for the corresponding QuaZip constructor. inline QuaZipPrivate(QuaZip *q): q(q), fileNameCodec(getDefaultFileNameCodec()), commentCodec(QTextCodec::codecForLocale()), ioDevice(NULL), mode(QuaZip::mdNotOpen), hasCurrentFile_f(false), zipError(UNZ_OK), dataDescriptorWritingEnabled(true), zip64(false), autoClose(true), utf8(false), osCode(defaultOsCode) { unzFile_f = NULL; zipFile_f = NULL; lastMappedDirectoryEntry.num_of_file = 0; lastMappedDirectoryEntry.pos_in_zip_directory = 0; } /// The constructor for the corresponding QuaZip constructor. inline QuaZipPrivate(QuaZip *q, const QString &zipName): q(q), fileNameCodec(getDefaultFileNameCodec()), commentCodec(QTextCodec::codecForLocale()), zipName(zipName), ioDevice(NULL), mode(QuaZip::mdNotOpen), hasCurrentFile_f(false), zipError(UNZ_OK), dataDescriptorWritingEnabled(true), zip64(false), autoClose(true), utf8(false), osCode(defaultOsCode) { unzFile_f = NULL; zipFile_f = NULL; lastMappedDirectoryEntry.num_of_file = 0; lastMappedDirectoryEntry.pos_in_zip_directory = 0; } /// The constructor for the corresponding QuaZip constructor. inline QuaZipPrivate(QuaZip *q, QIODevice *ioDevice): q(q), fileNameCodec(getDefaultFileNameCodec()), commentCodec(QTextCodec::codecForLocale()), ioDevice(ioDevice), mode(QuaZip::mdNotOpen), hasCurrentFile_f(false), zipError(UNZ_OK), dataDescriptorWritingEnabled(true), zip64(false), autoClose(true), utf8(false), osCode(defaultOsCode) { unzFile_f = NULL; zipFile_f = NULL; lastMappedDirectoryEntry.num_of_file = 0; lastMappedDirectoryEntry.pos_in_zip_directory = 0; } /// Returns either a list of file names or a list of QuaZipFileInfo. template bool getFileInfoList(QList *result) const; /// Stores map of filenames and file locations for unzipping inline void clearDirectoryMap(); inline void addCurrentFileToDirectoryMap(const QString &fileName); bool goToFirstUnmappedFile(); QHash directoryCaseSensitive; QHash directoryCaseInsensitive; unz64_file_pos lastMappedDirectoryEntry; static QTextCodec *defaultFileNameCodec; static uint defaultOsCode; }; QTextCodec *QuaZipPrivate::defaultFileNameCodec = NULL; uint QuaZipPrivate::defaultOsCode = QUAZIP_OS_UNIX; void QuaZipPrivate::clearDirectoryMap() { directoryCaseInsensitive.clear(); directoryCaseSensitive.clear(); lastMappedDirectoryEntry.num_of_file = 0; lastMappedDirectoryEntry.pos_in_zip_directory = 0; } void QuaZipPrivate::addCurrentFileToDirectoryMap(const QString &fileName) { if (!hasCurrentFile_f || fileName.isEmpty()) { return; } // Adds current file to filename map as fileName unz64_file_pos fileDirectoryPos; unzGetFilePos64(unzFile_f, &fileDirectoryPos); directoryCaseSensitive.insert(fileName, fileDirectoryPos); // Only add lowercase to directory map if not already there // ensures only map the first one seen QString lower = fileName.toLower(); if (!directoryCaseInsensitive.contains(lower)) directoryCaseInsensitive.insert(lower, fileDirectoryPos); // Mark last one if (fileDirectoryPos.pos_in_zip_directory > lastMappedDirectoryEntry.pos_in_zip_directory) lastMappedDirectoryEntry = fileDirectoryPos; } bool QuaZipPrivate::goToFirstUnmappedFile() { zipError = UNZ_OK; if (mode != QuaZip::mdUnzip) { qWarning("QuaZipPrivate::goToNextUnmappedFile(): ZIP is not open in mdUnzip mode"); return false; } // If not mapped anything, go to beginning if (lastMappedDirectoryEntry.pos_in_zip_directory == 0) { unzGoToFirstFile(unzFile_f); } else { // Goto the last one mapped, plus one unzGoToFilePos64(unzFile_f, &lastMappedDirectoryEntry); unzGoToNextFile(unzFile_f); } hasCurrentFile_f=zipError==UNZ_OK; if(zipError==UNZ_END_OF_LIST_OF_FILE) zipError=UNZ_OK; return hasCurrentFile_f; } QuaZip::QuaZip(): p(new QuaZipPrivate(this)) { } QuaZip::QuaZip(const QString& zipName): p(new QuaZipPrivate(this, zipName)) { } QuaZip::QuaZip(QIODevice *ioDevice): p(new QuaZipPrivate(this, ioDevice)) { } QuaZip::~QuaZip() { if(isOpen()) close(); delete p; } bool QuaZip::open(Mode mode, zlib_filefunc_def* ioApi) { p->zipError=UNZ_OK; if(isOpen()) { qWarning("QuaZip::open(): ZIP already opened"); return false; } QIODevice *ioDevice = p->ioDevice; if (ioDevice == NULL) { if (p->zipName.isEmpty()) { qWarning("QuaZip::open(): set either ZIP file name or IO device first"); return false; } else { ioDevice = new QFile(p->zipName); } } unsigned flags = 0; switch(mode) { case mdUnzip: if (ioApi == NULL) { if (p->autoClose) flags |= UNZ_AUTO_CLOSE; p->unzFile_f=unzOpenInternal(ioDevice, NULL, 1, flags); } else { // QuaZIP pre-zip64 compatibility mode p->unzFile_f=unzOpen2(ioDevice, ioApi); if (p->unzFile_f != NULL) { if (p->autoClose) { unzSetFlags(p->unzFile_f, UNZ_AUTO_CLOSE); } else { unzClearFlags(p->unzFile_f, UNZ_AUTO_CLOSE); } } } if(p->unzFile_f!=NULL) { if (ioDevice->isSequential()) { unzClose(p->unzFile_f); if (!p->zipName.isEmpty()) delete ioDevice; qWarning("QuaZip::open(): " "only mdCreate can be used with " "sequential devices"); return false; } p->mode=mode; p->ioDevice = ioDevice; return true; } else { p->zipError=UNZ_OPENERROR; if (!p->zipName.isEmpty()) delete ioDevice; return false; } case mdCreate: case mdAppend: case mdAdd: if (ioApi == NULL) { if (p->autoClose) flags |= ZIP_AUTO_CLOSE; if (p->dataDescriptorWritingEnabled) flags |= ZIP_WRITE_DATA_DESCRIPTOR; if (p->utf8) flags |= ZIP_ENCODING_UTF8; p->zipFile_f=zipOpen3(ioDevice, mode==mdCreate?APPEND_STATUS_CREATE: mode==mdAppend?APPEND_STATUS_CREATEAFTER: APPEND_STATUS_ADDINZIP, NULL, NULL, flags); } else { // QuaZIP pre-zip64 compatibility mode p->zipFile_f=zipOpen2(ioDevice, mode==mdCreate?APPEND_STATUS_CREATE: mode==mdAppend?APPEND_STATUS_CREATEAFTER: APPEND_STATUS_ADDINZIP, NULL, ioApi); if (p->zipFile_f != NULL) { zipSetFlags(p->zipFile_f, flags); } } if(p->zipFile_f!=NULL) { if (ioDevice->isSequential()) { if (mode != mdCreate) { zipClose(p->zipFile_f, NULL); qWarning("QuaZip::open(): " "only mdCreate can be used with " "sequential devices"); if (!p->zipName.isEmpty()) delete ioDevice; return false; } zipSetFlags(p->zipFile_f, ZIP_SEQUENTIAL); } p->mode=mode; p->ioDevice = ioDevice; return true; } else { p->zipError=UNZ_OPENERROR; if (!p->zipName.isEmpty()) delete ioDevice; return false; } default: qWarning("QuaZip::open(): unknown mode: %d", (int)mode); if (!p->zipName.isEmpty()) delete ioDevice; return false; break; } } void QuaZip::close() { p->zipError=UNZ_OK; switch(p->mode) { case mdNotOpen: qWarning("QuaZip::close(): ZIP is not open"); return; case mdUnzip: p->zipError=unzClose(p->unzFile_f); break; case mdCreate: case mdAppend: case mdAdd: p->zipError=zipClose(p->zipFile_f, p->comment.isNull() ? NULL : isUtf8Enabled() ? p->comment.toUtf8().constData() : p->commentCodec->fromUnicode(p->comment).constData()); break; default: qWarning("QuaZip::close(): unknown mode: %d", (int)p->mode); return; } // opened by name, need to delete the internal IO device if (!p->zipName.isEmpty()) { delete p->ioDevice; p->ioDevice = NULL; } p->clearDirectoryMap(); if(p->zipError==UNZ_OK) p->mode=mdNotOpen; } void QuaZip::setZipName(const QString& zipName) { if(isOpen()) { qWarning("QuaZip::setZipName(): ZIP is already open!"); return; } p->zipName=zipName; p->ioDevice = NULL; } void QuaZip::setIoDevice(QIODevice *ioDevice) { if(isOpen()) { qWarning("QuaZip::setIoDevice(): ZIP is already open!"); return; } p->ioDevice = ioDevice; p->zipName = QString(); } int QuaZip::getEntriesCount()const { QuaZip *fakeThis=(QuaZip*)this; // non-const fakeThis->p->zipError=UNZ_OK; if(p->mode!=mdUnzip) { qWarning("QuaZip::getEntriesCount(): ZIP is not open in mdUnzip mode"); return -1; } unz_global_info64 globalInfo; if((fakeThis->p->zipError=unzGetGlobalInfo64(p->unzFile_f, &globalInfo))!=UNZ_OK) return p->zipError; return (int)globalInfo.number_entry; } QString QuaZip::getComment()const { QuaZip *fakeThis=(QuaZip*)this; // non-const fakeThis->p->zipError=UNZ_OK; if(p->mode!=mdUnzip) { qWarning("QuaZip::getComment(): ZIP is not open in mdUnzip mode"); return QString(); } unz_global_info64 globalInfo; QByteArray comment; if((fakeThis->p->zipError=unzGetGlobalInfo64(p->unzFile_f, &globalInfo))!=UNZ_OK) return QString(); comment.resize(globalInfo.size_comment); if((fakeThis->p->zipError=unzGetGlobalComment(p->unzFile_f, comment.data(), comment.size())) < 0) return QString(); fakeThis->p->zipError = UNZ_OK; unsigned flags = 0; return (unzGetFileFlags(p->unzFile_f, &flags) == UNZ_OK) && (flags & UNZ_ENCODING_UTF8) ? QString::fromUtf8(comment) : p->commentCodec->toUnicode(comment); } bool QuaZip::setCurrentFile(const QString& fileName, CaseSensitivity cs) { p->zipError=UNZ_OK; if(p->mode!=mdUnzip) { qWarning("QuaZip::setCurrentFile(): ZIP is not open in mdUnzip mode"); return false; } if(fileName.isEmpty()) { p->hasCurrentFile_f=false; return true; } // Unicode-aware reimplementation of the unzLocateFile function if(p->unzFile_f==NULL) { p->zipError=UNZ_PARAMERROR; return false; } if(fileName.length()>MAX_FILE_NAME_LENGTH) { p->zipError=UNZ_PARAMERROR; return false; } // Find the file by name bool sens = convertCaseSensitivity(cs) == Qt::CaseSensitive; QString lower, current; if(!sens) lower=fileName.toLower(); p->hasCurrentFile_f=false; // Check the appropriate Map unz64_file_pos fileDirPos; fileDirPos.pos_in_zip_directory = 0; if (sens) { if (p->directoryCaseSensitive.contains(fileName)) fileDirPos = p->directoryCaseSensitive.value(fileName); } else { if (p->directoryCaseInsensitive.contains(lower)) fileDirPos = p->directoryCaseInsensitive.value(lower); } if (fileDirPos.pos_in_zip_directory != 0) { p->zipError = unzGoToFilePos64(p->unzFile_f, &fileDirPos); p->hasCurrentFile_f = p->zipError == UNZ_OK; } if (p->hasCurrentFile_f) return p->hasCurrentFile_f; // Not mapped yet, start from where we have got to so far for(bool more=p->goToFirstUnmappedFile(); more; more=goToNextFile()) { current=getCurrentFileName(); if(current.isEmpty()) return false; if(sens) { if(current==fileName) break; } else { if(current.toLower()==lower) break; } } return p->hasCurrentFile_f; } bool QuaZip::goToFirstFile() { p->zipError=UNZ_OK; if(p->mode!=mdUnzip) { qWarning("QuaZip::goToFirstFile(): ZIP is not open in mdUnzip mode"); return false; } p->zipError=unzGoToFirstFile(p->unzFile_f); p->hasCurrentFile_f=p->zipError==UNZ_OK; return p->hasCurrentFile_f; } bool QuaZip::goToNextFile() { p->zipError=UNZ_OK; if(p->mode!=mdUnzip) { qWarning("QuaZip::goToFirstFile(): ZIP is not open in mdUnzip mode"); return false; } p->zipError=unzGoToNextFile(p->unzFile_f); p->hasCurrentFile_f=p->zipError==UNZ_OK; if(p->zipError==UNZ_END_OF_LIST_OF_FILE) p->zipError=UNZ_OK; return p->hasCurrentFile_f; } bool QuaZip::getCurrentFileInfo(QuaZipFileInfo *info)const { QuaZipFileInfo64 info64; if (info == NULL) { // Very unlikely because of the overloads return false; } if (getCurrentFileInfo(&info64)) { info64.toQuaZipFileInfo(*info); return true; } else { return false; } } bool QuaZip::getCurrentFileInfo(QuaZipFileInfo64 *info)const { QuaZip *fakeThis=(QuaZip*)this; // non-const fakeThis->p->zipError=UNZ_OK; if(p->mode!=mdUnzip) { qWarning("QuaZip::getCurrentFileInfo(): ZIP is not open in mdUnzip mode"); return false; } unz_file_info64 info_z; QByteArray fileName; QByteArray extra; QByteArray comment; if(info==NULL) return false; if(!isOpen()||!hasCurrentFile()) return false; if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, &info_z, NULL, 0, NULL, 0, NULL, 0))!=UNZ_OK) return false; fileName.resize(info_z.size_filename); extra.resize(info_z.size_file_extra); comment.resize(info_z.size_file_comment); if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, NULL, fileName.data(), fileName.size(), extra.data(), extra.size(), comment.data(), comment.size()))!=UNZ_OK) return false; info->versionCreated=info_z.version; info->versionNeeded=info_z.version_needed; info->flags=info_z.flag; info->method=info_z.compression_method; info->crc=info_z.crc; info->compressedSize=info_z.compressed_size; info->uncompressedSize=info_z.uncompressed_size; info->diskNumberStart=info_z.disk_num_start; info->internalAttr=info_z.internal_fa; info->externalAttr=info_z.external_fa; info->name=(info->flags & UNZ_ENCODING_UTF8) ? QString::fromUtf8(fileName) : p->fileNameCodec->toUnicode(fileName); info->comment=(info->flags & UNZ_ENCODING_UTF8) ? QString::fromUtf8(comment) : p->commentCodec->toUnicode(comment); info->extra=extra; info->dateTime=QDateTime( QDate(info_z.tmu_date.tm_year, info_z.tmu_date.tm_mon+1, info_z.tmu_date.tm_mday), QTime(info_z.tmu_date.tm_hour, info_z.tmu_date.tm_min, info_z.tmu_date.tm_sec)); // Add to directory map p->addCurrentFileToDirectoryMap(info->name); return true; } QString QuaZip::getCurrentFileName()const { QuaZip *fakeThis=(QuaZip*)this; // non-const fakeThis->p->zipError=UNZ_OK; if(p->mode!=mdUnzip) { qWarning("QuaZip::getCurrentFileName(): ZIP is not open in mdUnzip mode"); return QString(); } if(!isOpen()||!hasCurrentFile()) return QString(); QByteArray fileName(MAX_FILE_NAME_LENGTH, 0); unz_file_info64 file_info; if((fakeThis->p->zipError=unzGetCurrentFileInfo64(p->unzFile_f, &file_info, fileName.data(), fileName.size(), NULL, 0, NULL, 0))!=UNZ_OK) return QString(); fileName.resize(file_info.size_filename); QString result = (file_info.flag & UNZ_ENCODING_UTF8) ? QString::fromUtf8(fileName) : p->fileNameCodec->toUnicode(fileName); if (result.isEmpty()) return result; // Add to directory map p->addCurrentFileToDirectoryMap(result); return result; } void QuaZip::setFileNameCodec(QTextCodec *fileNameCodec) { p->fileNameCodec=fileNameCodec; } void QuaZip::setFileNameCodec(const char *fileNameCodecName) { p->fileNameCodec=QTextCodec::codecForName(fileNameCodecName); } void QuaZip::setOsCode(uint osCode) { p->osCode = osCode; } uint QuaZip::getOsCode() const { return p->osCode; } QTextCodec *QuaZip::getFileNameCodec()const { return p->fileNameCodec; } void QuaZip::setCommentCodec(QTextCodec *commentCodec) { p->commentCodec=commentCodec; } void QuaZip::setCommentCodec(const char *commentCodecName) { p->commentCodec=QTextCodec::codecForName(commentCodecName); } QTextCodec *QuaZip::getCommentCodec()const { return p->commentCodec; } QString QuaZip::getZipName() const { return p->zipName; } QIODevice *QuaZip::getIoDevice() const { if (!p->zipName.isEmpty()) // opened by name, using an internal QIODevice return NULL; return p->ioDevice; } QuaZip::Mode QuaZip::getMode()const { return p->mode; } bool QuaZip::isOpen()const { return p->mode!=mdNotOpen; } int QuaZip::getZipError() const { return p->zipError; } void QuaZip::setComment(const QString& comment) { p->comment=comment; } bool QuaZip::hasCurrentFile()const { return p->hasCurrentFile_f; } unzFile QuaZip::getUnzFile() { return p->unzFile_f; } zipFile QuaZip::getZipFile() { return p->zipFile_f; } void QuaZip::setDataDescriptorWritingEnabled(bool enabled) { p->dataDescriptorWritingEnabled = enabled; } bool QuaZip::isDataDescriptorWritingEnabled() const { return p->dataDescriptorWritingEnabled; } template TFileInfo QuaZip_getFileInfo(QuaZip *zip, bool *ok); template<> QuaZipFileInfo QuaZip_getFileInfo(QuaZip *zip, bool *ok) { QuaZipFileInfo info; *ok = zip->getCurrentFileInfo(&info); return info; } template<> QuaZipFileInfo64 QuaZip_getFileInfo(QuaZip *zip, bool *ok) { QuaZipFileInfo64 info; *ok = zip->getCurrentFileInfo(&info); return info; } template<> QString QuaZip_getFileInfo(QuaZip *zip, bool *ok) { QString name = zip->getCurrentFileName(); *ok = !name.isEmpty(); return name; } template bool QuaZipPrivate::getFileInfoList(QList *result) const { QuaZipPrivate *fakeThis=const_cast(this); fakeThis->zipError=UNZ_OK; if (mode!=QuaZip::mdUnzip) { qWarning("QuaZip::getFileNameList/getFileInfoList(): " "ZIP is not open in mdUnzip mode"); return false; } QString currentFile; if (q->hasCurrentFile()) { currentFile = q->getCurrentFileName(); } if (q->goToFirstFile()) { do { bool ok; result->append(QuaZip_getFileInfo(q, &ok)); if (!ok) return false; } while (q->goToNextFile()); } if (zipError != UNZ_OK) return false; if (currentFile.isEmpty()) { if (!q->goToFirstFile()) return false; } else { if (!q->setCurrentFile(currentFile)) return false; } return true; } QStringList QuaZip::getFileNameList() const { QStringList list; if (p->getFileInfoList(&list)) return list; else return QStringList(); } QList QuaZip::getFileInfoList() const { QList list; if (p->getFileInfoList(&list)) return list; else return QList(); } QList QuaZip::getFileInfoList64() const { QList list; if (p->getFileInfoList(&list)) return list; else return QList(); } Qt::CaseSensitivity QuaZip::convertCaseSensitivity(QuaZip::CaseSensitivity cs) { if (cs == csDefault) { #ifdef Q_OS_WIN return Qt::CaseInsensitive; #else return Qt::CaseSensitive; #endif } else { return cs == csSensitive ? Qt::CaseSensitive : Qt::CaseInsensitive; } } void QuaZip::setDefaultFileNameCodec(QTextCodec *codec) { QuaZipPrivate::defaultFileNameCodec = codec; } void QuaZip::setDefaultFileNameCodec(const char *codecName) { setDefaultFileNameCodec(QTextCodec::codecForName(codecName)); } void QuaZip::setDefaultOsCode(uint osCode) { QuaZipPrivate::defaultOsCode = osCode; } uint QuaZip::getDefaultOsCode() { return QuaZipPrivate::defaultOsCode; } void QuaZip::setZip64Enabled(bool zip64) { p->zip64 = zip64; } bool QuaZip::isZip64Enabled() const { return p->zip64; } void QuaZip::setUtf8Enabled(bool utf8) { p->utf8 = utf8; } bool QuaZip::isUtf8Enabled() const { return p->utf8; } bool QuaZip::isAutoClose() const { return p->autoClose; } void QuaZip::setAutoClose(bool autoClose) const { p->autoClose = autoClose; } quazip-0.9.1/quazip/quazip.h000066400000000000000000000645521366246114300160470ustar00rootroot00000000000000#ifndef QUA_ZIP_H #define QUA_ZIP_H /* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant, see quazip/(un)zip.h files for details, basically it's zlib license. **/ #include #include #include #include "zip.h" #include "unzip.h" #include "quazip_global.h" #include "quazipfileinfo.h" // just in case it will be defined in the later versions of the ZIP/UNZIP #ifndef UNZ_OPENERROR // define additional error code #define UNZ_OPENERROR -1000 #endif class QuaZipPrivate; /// ZIP archive. /** \class QuaZip quazip.h * This class implements basic interface to the ZIP archive. It can be * used to read table contents of the ZIP archive and retreiving * information about the files inside it. * * You can also use this class to open files inside archive by passing * pointer to the instance of this class to the constructor of the * QuaZipFile class. But see QuaZipFile::QuaZipFile(QuaZip*, QObject*) * for the possible pitfalls. * * This class is indended to provide interface to the ZIP subpackage of * the ZIP/UNZIP package as well as to the UNZIP subpackage. But * currently it supports only UNZIP. * * The use of this class is simple - just create instance using * constructor, then set ZIP archive file name using setFile() function * (if you did not passed the name to the constructor), then open() and * then use different functions to work with it! Well, if you are * paranoid, you may also wish to call close before destructing the * instance, to check for errors on close. * * You may also use getUnzFile() and getZipFile() functions to get the * ZIP archive handle and use it with ZIP/UNZIP package API directly. * * This class supports localized file names inside ZIP archive, but you * have to set up proper codec with setCodec() function. By default, * locale codec will be used, which is probably ok for UNIX systems, but * will almost certainly fail with ZIP archives created in Windows. This * is because Windows ZIP programs have strange habit of using DOS * encoding for file names in ZIP archives. For example, ZIP archive * with cyrillic names created in Windows will have file names in \c * IBM866 encoding instead of \c WINDOWS-1251. I think that calling one * function is not much trouble, but for true platform independency it * would be nice to have some mechanism for file name encoding auto * detection using locale information. Does anyone know a good way to do * it? **/ class QUAZIP_EXPORT QuaZip { friend class QuaZipPrivate; public: /// Useful constants. enum Constants { MAX_FILE_NAME_LENGTH=256 /**< Maximum file name length. Taken from \c UNZ_MAXFILENAMEINZIP constant in unzip.c. */ }; /// Open mode of the ZIP file. enum Mode { mdNotOpen, ///< ZIP file is not open. This is the initial mode. mdUnzip, ///< ZIP file is open for reading files inside it. mdCreate, ///< ZIP file was created with open() call. mdAppend, /**< ZIP file was opened in append mode. This refers to * \c APPEND_STATUS_CREATEAFTER mode in ZIP/UNZIP package * and means that zip is appended to some existing file * what is useful when that file contains * self-extractor code. This is obviously \em not what * you whant to use to add files to the existing ZIP * archive. **/ mdAdd ///< ZIP file was opened for adding files in the archive. }; /// Case sensitivity for the file names. /** This is what you specify when accessing files in the archive. * Works perfectly fine with any characters thanks to Qt's great * unicode support. This is different from ZIP/UNZIP API, where * only US-ASCII characters was supported. **/ enum CaseSensitivity { csDefault=0, ///< Default for platform. Case sensitive for UNIX, not for Windows. csSensitive=1, ///< Case sensitive. csInsensitive=2 ///< Case insensitive. }; /// Returns the actual case sensitivity for the specified QuaZIP one. /** \param cs The value to convert. \returns If CaseSensitivity::csDefault, then returns the default file name case sensitivity for the platform. Otherwise, just returns the appropriate value from the Qt::CaseSensitivity enum. */ static Qt::CaseSensitivity convertCaseSensitivity( CaseSensitivity cs); private: QuaZipPrivate *p; // not (and will not be) implemented QuaZip(const QuaZip& that); // not (and will not be) implemented QuaZip& operator=(const QuaZip& that); public: /// Constructs QuaZip object. /** Call setName() before opening constructed object. */ QuaZip(); /// Constructs QuaZip object associated with ZIP file \a zipName. QuaZip(const QString& zipName); /// Constructs QuaZip object associated with ZIP file represented by \a ioDevice. /** The IO device must be seekable, otherwise an error will occur when opening. */ QuaZip(QIODevice *ioDevice); /// Destroys QuaZip object. /** Calls close() if necessary. */ ~QuaZip(); /// Opens ZIP file. /** * Argument \a mode specifies open mode of the ZIP archive. See Mode * for details. Note that there is zipOpen2() function in the * ZIP/UNZIP API which accepts \a globalcomment argument, but it * does not use it anywhere, so this open() function does not have this * argument. See setComment() if you need to set global comment. * * If the ZIP file is accessed via explicitly set QIODevice, then * this device is opened in the necessary mode. If the device was * already opened by some other means, then QuaZIP checks if the * open mode is compatible to the mode needed for the requested operation. * If necessary, seeking is performed to position the device properly. * * \return \c true if successful, \c false otherwise. * * \note ZIP/UNZIP API open calls do not return error code - they * just return \c NULL indicating an error. But to make things * easier, quazip.h header defines additional error code \c * UNZ_ERROROPEN and getZipError() will return it if the open call * of the ZIP/UNZIP API returns \c NULL. * * Argument \a ioApi specifies IO function set for ZIP/UNZIP * package to use. See unzip.h, zip.h and ioapi.h for details. Note * that IO API for QuaZip is different from the original package. * The file path argument was changed to be of type \c voidpf, and * QuaZip passes a QIODevice pointer there. This QIODevice is either * set explicitly via setIoDevice() or the QuaZip(QIODevice*) * constructor, or it is created internally when opening the archive * by its file name. The default API (qioapi.cpp) just delegates * everything to the QIODevice API. Not only this allows to use a * QIODevice instead of file name, but also has a nice side effect * of raising the file size limit from 2G to 4G (in non-zip64 archives). * * \note If the zip64 support is needed, the ioApi argument \em must be NULL * because due to the backwards compatibility issues it can be used to * provide a 32-bit API only. * * \note If the \ref QuaZip::setAutoClose() "no-auto-close" feature is used, * then the \a ioApi argument \em should be NULL because the old API * doesn't support the 'fake close' operation, causing slight memory leaks * and other possible troubles (like closing the output device in case * when an error occurs during opening). * * In short: just forget about the \a ioApi argument and you'll be * fine. **/ bool open(Mode mode, zlib_filefunc_def *ioApi =NULL); /// Closes ZIP file. /** Call getZipError() to determine if the close was successful. * * If the file was opened by name, then the underlying QIODevice is closed * and deleted. * * If the underlying QIODevice was set explicitly using setIoDevice() or * the appropriate constructor, then it is closed if the auto-close flag * is set (which it is by default). Call setAutoClose() to clear the * auto-close flag if this behavior is undesirable. * * Since Qt 5.1, the QSaveFile was introduced. It breaks the QIODevice API * by making close() private and crashing the application if it is called * from the base class where it is public. It is an excellent example * of poor design that illustrates why you should never ever break * an is-a relationship between the base class and a subclass. QuaZIP * works around this bug by checking if the QIODevice is an instance * of QSaveFile, using qobject_cast<>, and if it is, calls * QSaveFile::commit() instead of close(). It is a really ugly hack, * but at least it makes your programs work instead of crashing. Note that * if the auto-close flag is cleared, then this is a non-issue, and * commit() isn't called. */ void close(); /// Sets the codec used to encode/decode file names inside archive. /** This is necessary to access files in the ZIP archive created * under Windows with non-latin characters in file names. For * example, file names with cyrillic letters will be in \c IBM866 * encoding. **/ void setFileNameCodec(QTextCodec *fileNameCodec); /// Sets the codec used to encode/decode file names inside archive. /** \overload * Equivalent to calling setFileNameCodec(QTextCodec::codecForName(codecName)); **/ void setFileNameCodec(const char *fileNameCodecName); /// Sets the OS code (highest 8 bits of the “version made by” field) for new files. /** There is currently no way to specify this for each file individually, except by calling this function before opening each file. If this function is not called, then the default OS code will be used. The default code is set by calling setDefaultOsCode(). The default value at the moment of QuaZip creation will be used. */ void setOsCode(uint osCode); /// Returns the OS code for new files. uint getOsCode() const; /// Returns the codec used to encode/decode comments inside archive. QTextCodec* getFileNameCodec() const; /// Sets the codec used to encode/decode comments inside archive. /** This codec defaults to locale codec, which is probably ok. **/ void setCommentCodec(QTextCodec *commentCodec); /// Sets the codec used to encode/decode comments inside archive. /** \overload * Equivalent to calling setCommentCodec(QTextCodec::codecForName(codecName)); **/ void setCommentCodec(const char *commentCodecName); /// Returns the codec used to encode/decode comments inside archive. QTextCodec* getCommentCodec() const; /// Returns the name of the ZIP file. /** Returns null string if no ZIP file name has been set, for * example when the QuaZip instance is set up to use a QIODevice * instead. * \sa setZipName(), setIoDevice(), getIoDevice() **/ QString getZipName() const; /// Sets the name of the ZIP file. /** Does nothing if the ZIP file is open. * * Does not reset error code returned by getZipError(). * \sa setIoDevice(), getIoDevice(), getZipName() **/ void setZipName(const QString& zipName); /// Returns the device representing this ZIP file. /** Returns null string if no device has been set explicitly, for * example when opening a ZIP file by name. * \sa setIoDevice(), getZipName(), setZipName() **/ QIODevice *getIoDevice() const; /// Sets the device representing the ZIP file. /** Does nothing if the ZIP file is open. * * Does not reset error code returned by getZipError(). * \sa getIoDevice(), getZipName(), setZipName() **/ void setIoDevice(QIODevice *ioDevice); /// Returns the mode in which ZIP file was opened. Mode getMode() const; /// Returns \c true if ZIP file is open, \c false otherwise. bool isOpen() const; /// Returns the error code of the last operation. /** Returns \c UNZ_OK if the last operation was successful. * * Error code resets to \c UNZ_OK every time you call any function * that accesses something inside ZIP archive, even if it is \c * const (like getEntriesCount()). open() and close() calls reset * error code too. See documentation for the specific functions for * details on error detection. **/ int getZipError() const; /// Returns number of the entries in the ZIP central directory. /** Returns negative error code in the case of error. The same error * code will be returned by subsequent getZipError() call. **/ int getEntriesCount() const; /// Returns global comment in the ZIP file. QString getComment() const; /// Sets the global comment in the ZIP file. /** The comment will be written to the archive on close operation. * QuaZip makes a distinction between a null QByteArray() comment * and an empty "" comment in the QuaZip::mdAdd mode. * A null comment is the default and it means "don't change * the comment". An empty comment removes the original comment. * * \sa open() **/ void setComment(const QString& comment); /// Sets the current file to the first file in the archive. /** Returns \c true on success, \c false otherwise. Call * getZipError() to get the error code. **/ bool goToFirstFile(); /// Sets the current file to the next file in the archive. /** Returns \c true on success, \c false otherwise. Call * getZipError() to determine if there was an error. * * Should be used only in QuaZip::mdUnzip mode. * * \note If the end of file was reached, getZipError() will return * \c UNZ_OK instead of \c UNZ_END_OF_LIST_OF_FILE. This is to make * things like this easier: * \code * for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile()) { * // do something * } * if(zip.getZipError()==UNZ_OK) { * // ok, there was no error * } * \endcode **/ bool goToNextFile(); /// Sets current file by its name. /** Returns \c true if successful, \c false otherwise. Argument \a * cs specifies case sensitivity of the file name. Call * getZipError() in the case of a failure to get error code. * * This is not a wrapper to unzLocateFile() function. That is * because I had to implement locale-specific case-insensitive * comparison. * * Here are the differences from the original implementation: * * - If the file was not found, error code is \c UNZ_OK, not \c * UNZ_END_OF_LIST_OF_FILE (see also goToNextFile()). * - If this function fails, it unsets the current file rather than * resetting it back to what it was before the call. * * If \a fileName is null string then this function unsets the * current file and return \c true. Note that you should close the * file first if it is open! See * QuaZipFile::QuaZipFile(QuaZip*,QObject*) for the details. * * Should be used only in QuaZip::mdUnzip mode. * * \sa setFileNameCodec(), CaseSensitivity **/ bool setCurrentFile(const QString& fileName, CaseSensitivity cs =csDefault); /// Returns \c true if the current file has been set. bool hasCurrentFile() const; /// Retrieves information about the current file. /** Fills the structure pointed by \a info. Returns \c true on * success, \c false otherwise. In the latter case structure pointed * by \a info remains untouched. If there was an error, * getZipError() returns error code. * * Should be used only in QuaZip::mdUnzip mode. * * Does nothing and returns \c false in any of the following cases. * - ZIP is not open; * - ZIP does not have current file. * * In both cases getZipError() returns \c UNZ_OK since there * is no ZIP/UNZIP API call. * * This overload doesn't support zip64, but will work OK on zip64 archives * except that if one of the sizes (compressed or uncompressed) is greater * than 0xFFFFFFFFu, it will be set to exactly 0xFFFFFFFFu. * * \sa getCurrentFileInfo(QuaZipFileInfo64* info)const * \sa QuaZipFileInfo64::toQuaZipFileInfo(QuaZipFileInfo&)const **/ bool getCurrentFileInfo(QuaZipFileInfo* info)const; /// Retrieves information about the current file. /** \overload * * This function supports zip64. If the archive doesn't use zip64, it is * completely equivalent to getCurrentFileInfo(QuaZipFileInfo* info) * except for the argument type. * * \sa **/ bool getCurrentFileInfo(QuaZipFileInfo64* info)const; /// Returns the current file name. /** Equivalent to calling getCurrentFileInfo() and then getting \c * name field of the QuaZipFileInfo structure, but faster and more * convenient. * * Should be used only in QuaZip::mdUnzip mode. **/ QString getCurrentFileName()const; /// Returns \c unzFile handle. /** You can use this handle to directly call UNZIP part of the * ZIP/UNZIP package functions (see unzip.h). * * \warning When using the handle returned by this function, please * keep in mind that QuaZip class is unable to detect any changes * you make in the ZIP file state (e. g. changing current file, or * closing the handle). So please do not do anything with this * handle that is possible to do with the functions of this class. * Or at least return the handle in the original state before * calling some another function of this class (including implicit * destructor calls and calls from the QuaZipFile objects that refer * to this QuaZip instance!). So if you have changed the current * file in the ZIP archive - then change it back or you may * experience some strange behavior or even crashes. **/ unzFile getUnzFile(); /// Returns \c zipFile handle. /** You can use this handle to directly call ZIP part of the * ZIP/UNZIP package functions (see zip.h). Warnings about the * getUnzFile() function also apply to this function. **/ zipFile getZipFile(); /// Changes the data descriptor writing mode. /** According to the ZIP format specification, a file inside archive may have a data descriptor immediately following the file data. This is reflected by a special flag in the local file header and in the central directory. By default, QuaZIP sets this flag and writes the data descriptor unless both method and level were set to 0, in which case it operates in 1.0-compatible mode and never writes data descriptors. By setting this flag to false, it is possible to disable data descriptor writing, thus increasing compatibility with archive readers that don't understand this feature of the ZIP file format. Setting this flag affects all the QuaZipFile instances that are opened after this flag is set. The data descriptor writing mode is enabled by default. Note that if the ZIP archive is written into a QIODevice for which QIODevice::isSequential() returns \c true, then the data descriptor is mandatory and will be written even if this flag is set to false. \param enabled If \c true, enable local descriptor writing, disable it otherwise. \sa QuaZipFile::isDataDescriptorWritingEnabled() */ void setDataDescriptorWritingEnabled(bool enabled); /// Returns the data descriptor default writing mode. /** \sa setDataDescriptorWritingEnabled() */ bool isDataDescriptorWritingEnabled() const; /// Returns a list of files inside the archive. /** \return A list of file names or an empty list if there was an error or if the archive is empty (call getZipError() to figure out which). \sa getFileInfoList() */ QStringList getFileNameList() const; /// Returns information list about all files inside the archive. /** \return A list of QuaZipFileInfo objects or an empty list if there was an error or if the archive is empty (call getZipError() to figure out which). This function doesn't support zip64, but will still work with zip64 archives, converting results using QuaZipFileInfo64::toQuaZipFileInfo(). If all file sizes are below 4 GB, it will work just fine. \sa getFileNameList() \sa getFileInfoList64() */ QList getFileInfoList() const; /// Returns information list about all files inside the archive. /** \overload This function supports zip64. \sa getFileNameList() \sa getFileInfoList() */ QList getFileInfoList64() const; /// Enables the zip64 mode. /** * @param zip64 If \c true, the zip64 mode is enabled, disabled otherwise. * * Once this is enabled, all new files (until the mode is disabled again) * will be created in the zip64 mode, thus enabling the ability to write * files larger than 4 GB. By default, the zip64 mode is off due to * compatibility reasons. * * Note that this does not affect the ability to read zip64 archives in any * way. * * \sa isZip64Enabled() */ void setZip64Enabled(bool zip64); /// Returns whether the zip64 mode is enabled. /** * @return \c true if and only if the zip64 mode is enabled. * * \sa setZip64Enabled() */ bool isZip64Enabled() const; /// Enables the use of UTF-8 encoding for file names and comments text. /** * @param utf8 If \c true, the UTF-8 mode is enabled, disabled otherwise. * * Once this is enabled, the names of all new files and comments text (until * the mode is disabled again) will be encoded in UTF-8 encoding, and the * version to extract will be set to 6.3 (63) in ZIP header. By default, * the UTF-8 mode is off due to compatibility reasons. * * Note that when extracting ZIP archives, the UTF-8 mode is determined from * ZIP file header, not from this flag. * * \sa isUtf8Enabled() */ void setUtf8Enabled(bool utf8); /// Returns whether the UTF-8 encoding mode is enabled. /** * @return \c true if and only if the UTF-8 mode is enabled. * * \sa setUtf8Enabled() */ bool isUtf8Enabled() const; /// Returns the auto-close flag. /** @sa setAutoClose() */ bool isAutoClose() const; /// Sets or unsets the auto-close flag. /** By default, QuaZIP opens the underlying QIODevice when open() is called, and closes it when close() is called. In some cases, when the device is set explicitly using setIoDevice(), it may be desirable to leave the device open. If the auto-close flag is unset using this method, then the device isn't closed automatically if it was set explicitly. If it is needed to clear this flag, it is recommended to do so before opening the archive because otherwise QuaZIP may close the device during the open() call if an error is encountered after the device is opened. If the device was not set explicitly, but rather the setZipName() or the appropriate constructor was used to set the ZIP file name instead, then the auto-close flag has no effect, and the internal device is closed nevertheless because there is no other way to close it. @sa isAutoClose() @sa setIoDevice() */ void setAutoClose(bool autoClose) const; /// Sets the default file name codec to use. /** * The default codec is used by the constructors, so calling this function * won't affect the QuaZip instances already created at that moment. * * The codec specified here can be overriden by calling setFileNameCodec(). * If neither function is called, QTextCodec::codecForLocale() will be used * to decode or encode file names. Use this function with caution if * the application uses other libraries that depend on QuaZIP. Those * libraries can either call this function by themselves, thus overriding * your setting or can rely on the default encoding, thus failing * mysteriously if you change it. For these reasons, it isn't recommended * to use this function if you are developing a library, not an application. * Instead, ask your library users to call it in case they need specific * encoding. * * In most cases, using setFileNameCodec() instead is the right choice. * However, if you depend on third-party code that uses QuaZIP, then the * reasons stated above can actually become a reason to use this function * in case the third-party code in question fails because it doesn't * understand the encoding you need and doesn't provide a way to specify it. * This applies to the JlCompress class as well, as it was contributed and * doesn't support explicit encoding parameters. * * In short: use setFileNameCodec() when you can, resort to * setDefaultFileNameCodec() when you don't have access to the QuaZip * instance. * * @param codec The codec to use by default. If NULL, resets to default. */ static void setDefaultFileNameCodec(QTextCodec *codec); /** * @overload * Equivalent to calling * setDefaultFileNameCodec(QTextCodec::codecForName(codecName)). */ static void setDefaultFileNameCodec(const char *codecName); /// Sets default OS code. /** * @sa setOsCode() */ static void setDefaultOsCode(uint osCode); /// Returns default OS code. /** * @sa getOsCode() */ static uint getDefaultOsCode(); }; #endif quazip-0.9.1/quazip/quazip.pri000066400000000000000000000016471366246114300164060ustar00rootroot00000000000000INCLUDEPATH += $$PWD DEPENDPATH += $$PWD HEADERS += \ $$PWD/minizip_crypt.h \ $$PWD/ioapi.h \ $$PWD/JlCompress.h \ $$PWD/quaadler32.h \ $$PWD/quachecksum32.h \ $$PWD/quacrc32.h \ $$PWD/quagzipfile.h \ $$PWD/quaziodevice.h \ $$PWD/quazipdir.h \ $$PWD/quazipfile.h \ $$PWD/quazipfileinfo.h \ $$PWD/quazip_global.h \ $$PWD/quazip.h \ $$PWD/quazipnewinfo.h \ $$PWD/unzip.h \ $$PWD/zip.h SOURCES += $$PWD/qioapi.cpp \ $$PWD/JlCompress.cpp \ $$PWD/quaadler32.cpp \ $$PWD/quacrc32.cpp \ $$PWD/quagzipfile.cpp \ $$PWD/quaziodevice.cpp \ $$PWD/quazip.cpp \ $$PWD/quazipdir.cpp \ $$PWD/quazipfile.cpp \ $$PWD/quazipfileinfo.cpp \ $$PWD/quazipnewinfo.cpp \ $$PWD/unzip.c \ $$PWD/zip.c quazip-0.9.1/quazip/quazip.pro000066400000000000000000000063321366246114300164100ustar00rootroot00000000000000TEMPLATE = lib CONFIG += qt warn_on QT -= gui # Creating pkgconfig .pc file CONFIG += create_prl no_install_prl create_pc QMAKE_PKGCONFIG_PREFIX = $$PREFIX QMAKE_PKGCONFIG_INCDIR = $$headers.path QMAKE_PKGCONFIG_REQUIRES = Qt5Core # The ABI version. !win32:VERSION = 1.0.0 # 1.0.0 is the first stable ABI. # The next binary incompatible change will be 2.0.0 and so on. # The existing QuaZIP policy on changing ABI requires to bump the # major version of QuaZIP itself as well. Note that there may be # other reasons for chaging the major version of QuaZIP, so # in case where there is a QuaZIP major version bump but no ABI change, # the VERSION variable will stay the same. # For example: # QuaZIP 1.0 is released after some 0.x, keeping binary compatibility. # VERSION stays 1.0.0. # Then some binary incompatible change is introduced. QuaZIP goes up to # 2.0, VERSION to 2.0.0. # And so on. greaterThan(QT_MAJOR_VERSION, 4) { # disable all the Qt APIs deprecated before Qt 6.0.0 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 } # This one handles dllimport/dllexport directives. DEFINES += QUAZIP_BUILD DEFINES += QT_NO_CAST_FROM_ASCII DEFINES += QT_NO_CAST_TO_ASCII # You'll need to define this one manually if using a build system other # than qmake or using QuaZIP sources directly in your project. CONFIG(staticlib): DEFINES += QUAZIP_STATIC # Input include(quazip.pri) CONFIG(debug, debug|release) { mac: TARGET = $$join(TARGET,,,_debug) win32: TARGET = $$join(TARGET,,,d) } unix:!symbian { headers.path=$$PREFIX/include/quazip headers.files=$$HEADERS target.path=$$PREFIX/lib/$${LIB_ARCH} QMAKE_PKGCONFIG_DESTDIR = pkgconfig INSTALLS += headers target OBJECTS_DIR=.obj MOC_DIR=.moc } win32 { headers.path=$$PREFIX/include/quazip headers.files=$$HEADERS INSTALLS += headers target CONFIG(staticlib){ target.path=$$PREFIX/lib QMAKE_PKGCONFIG_LIBDIR = $$PREFIX/lib/ } else { target.path=$$PREFIX/bin QMAKE_PKGCONFIG_LIBDIR = $$PREFIX/bin/ } ## odd, this path seems to be relative to the ## target.path, so if we install the .dll into ## the 'bin' dir, the .pc will go there as well, ## unless have hack the needed path... ## TODO any nicer solution? QMAKE_PKGCONFIG_DESTDIR = ../lib/pkgconfig # workaround for qdatetime.h macro bug DEFINES += NOMINMAX } symbian { # Note, on Symbian you may run into troubles with LGPL. # The point is, if your application uses some version of QuaZip, # and a newer binary compatible version of QuaZip is released, then # the users of your application must be able to relink it with the # new QuaZip version. For example, to take advantage of some QuaZip # bug fixes. # This is probably best achieved by building QuaZip as a static # library and providing linkable object files of your application, # so users can relink it. CONFIG += staticlib CONFIG += debug_and_release LIBS += -lezip #Export headers to SDK Epoc32/include directory exportheaders.sources = $$HEADERS exportheaders.path = quazip for(header, exportheaders.sources) { BLD_INF_RULES.prj_exports += "$$header $$exportheaders.path/$$basename(header)" } } quazip-0.9.1/quazip/quazip.sln000066400000000000000000000015621366246114300164040ustar00rootroot00000000000000 Microsoft Visual Studio Solution File, Format Version 10.00 # Visual C++ Express 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "quazip", "quazip.vcproj", "{E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Debug|Win32.ActiveCfg = Debug|Win32 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Debug|Win32.Build.0 = Debug|Win32 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Release|Win32.ActiveCfg = Release|Win32 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal quazip-0.9.1/quazip/quazip.vcproj000066400000000000000000000133201366246114300171060ustar00rootroot00000000000000 quazip-0.9.1/quazip/quazip.vcxproj000066400000000000000000000222531366246114300173030ustar00rootroot00000000000000 Debug Win32 Debug x64 Release Win32 Release x64 {E4AC5F56-B711-4F0E-BC83-CDE8B6CD53AD} Win32Proj DynamicLibrary v120 DynamicLibrary v120 DynamicLibrary v120 DynamicLibrary v120 <_ProjectFileVersion>10.0.30319.1 Debug\ Debug\ true true Release\ Release\ true true Disabled WIN32;_DEBUG;_WINDOWS;QUAZIP_BUILD;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL Level3 EditAndContinue QtCored4.lib;%(AdditionalDependencies) true Windows MachineX86 Disabled WIN32;_DEBUG;_WINDOWS;QUAZIP_BUILD;%(PreprocessorDefinitions) EnableFastChecks MultiThreadedDebugDLL Level3 ProgramDatabase QtCored4.lib;%(AdditionalDependencies) true Windows WIN32;NDEBUG;_WINDOWS;QUAZIP_BUILD;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase Qt5Core.lib;%(AdditionalDependencies) true Windows true true MachineX86 WIN32;NDEBUG;_WINDOWS;QUAZIP_BUILD;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase Qt5Core.lib;zlibwapi.lib;%(AdditionalDependencies) true Windows true true quazip-0.9.1/quazip/quazip.vcxproj.filters000066400000000000000000000075461366246114300207620ustar00rootroot00000000000000 {93995380-89BD-4b04-88EB-625FBE52EBFB} h;hpp;hxx;hm;inl;inc;xsd {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx {4FC737F1-C7A5-4376-A066-2A32D752A2FF} cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Header Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files Source Files quazip-0.9.1/quazip/quazip_global.h000066400000000000000000000035751366246114300173650ustar00rootroot00000000000000#ifndef QUAZIP_GLOBAL_H #define QUAZIP_GLOBAL_H /* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include /** This is automatically defined when building a static library, but when including QuaZip sources directly into a project, QUAZIP_STATIC should be defined explicitly to avoid possible troubles with unnecessary importing/exporting. */ #ifdef QUAZIP_STATIC #define QUAZIP_EXPORT #else /** * When building a DLL with MSVC, QUAZIP_BUILD must be defined. * qglobal.h takes care of defining Q_DECL_* correctly for msvc/gcc. */ #if defined(QUAZIP_BUILD) #define QUAZIP_EXPORT Q_DECL_EXPORT #else #define QUAZIP_EXPORT Q_DECL_IMPORT #endif #endif // QUAZIP_STATIC #ifdef __GNUC__ #define QUAZIP_UNUSED __attribute__((__unused__)) #else #define QUAZIP_UNUSED #endif #define QUAZIP_EXTRA_NTFS_MAGIC 0x000Au #define QUAZIP_EXTRA_NTFS_TIME_MAGIC 0x0001u #define QUAZIP_EXTRA_EXT_TIME_MAGIC 0x5455u #define QUAZIP_EXTRA_EXT_MOD_TIME_FLAG 1 #define QUAZIP_EXTRA_EXT_AC_TIME_FLAG 2 #define QUAZIP_EXTRA_EXT_CR_TIME_FLAG 4 #endif // QUAZIP_GLOBAL_H quazip-0.9.1/quazip/quazipdir.cpp000066400000000000000000000411521366246114300170700ustar00rootroot00000000000000/* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include "quazipdir.h" #include #include /// \cond internal class QuaZipDirPrivate: public QSharedData { friend class QuaZipDir; private: QuaZipDirPrivate(QuaZip *zip, const QString &dir = QString()): zip(zip), dir(dir), caseSensitivity(QuaZip::csDefault), filter(QDir::NoFilter), sorting(QDir::NoSort) {} QuaZip *zip; QString dir; QuaZip::CaseSensitivity caseSensitivity; QDir::Filters filter; QStringList nameFilters; QDir::SortFlags sorting; template bool entryInfoList(QStringList nameFilters, QDir::Filters filter, QDir::SortFlags sort, TFileInfoList &result) const; inline QString simplePath() const {return QDir::cleanPath(dir);} }; /// \endcond QuaZipDir::QuaZipDir(const QuaZipDir &that): d(that.d) { } QuaZipDir::QuaZipDir(QuaZip *zip, const QString &dir): d(new QuaZipDirPrivate(zip, dir)) { if (d->dir.startsWith(QLatin1String("/"))) d->dir = d->dir.mid(1); } QuaZipDir::~QuaZipDir() { } bool QuaZipDir::operator==(const QuaZipDir &that) { return d->zip == that.d->zip && d->dir == that.d->dir; } QuaZipDir& QuaZipDir::operator=(const QuaZipDir &that) { this->d = that.d; return *this; } QString QuaZipDir::operator[](int pos) const { return entryList().at(pos); } QuaZip::CaseSensitivity QuaZipDir::caseSensitivity() const { return d->caseSensitivity; } bool QuaZipDir::cd(const QString &directoryName) { if (directoryName == QLatin1String("/")) { d->dir = QLatin1String(""); return true; } QString dirName = directoryName; if (dirName.endsWith(QLatin1String("/"))) dirName.chop(1); if (dirName.contains(QLatin1String("/"))) { QuaZipDir dir(*this); if (dirName.startsWith(QLatin1String("/"))) { #ifdef QUAZIP_QUAZIPDIR_DEBUG qDebug("QuaZipDir::cd(%s): going to /", dirName.toUtf8().constData()); #endif if (!dir.cd(QLatin1String("/"))) return false; } QStringList path = dirName.split(QLatin1String("/"), QString::SkipEmptyParts); for (QStringList::const_iterator i = path.constBegin(); i != path.constEnd(); ++i) { const QString &step = *i; #ifdef QUAZIP_QUAZIPDIR_DEBUG qDebug("QuaZipDir::cd(%s): going to %s", dirName.toUtf8().constData(), step.toUtf8().constData()); #endif if (!dir.cd(step)) return false; } d->dir = dir.path(); return true; } else { // no '/' if (dirName == QLatin1String(".")) { return true; } else if (dirName == QLatin1String("..")) { if (isRoot()) { return false; } else { int slashPos = d->dir.lastIndexOf(QLatin1String("/")); if (slashPos == -1) { d->dir = QLatin1String(""); } else { d->dir = d->dir.left(slashPos); } return true; } } else { // a simple subdirectory if (exists(dirName)) { if (isRoot()) d->dir = dirName; else d->dir += QLatin1String("/") + dirName; return true; } else { return false; } } } } bool QuaZipDir::cdUp() { return cd(QLatin1String("..")); } uint QuaZipDir::count() const { return entryList().count(); } QString QuaZipDir::dirName() const { return QDir(d->dir).dirName(); } QuaZipFileInfo64 QuaZipDir_getFileInfo(QuaZip *zip, bool *ok, const QString &relativeName, bool isReal) { QuaZipFileInfo64 info; if (isReal) { *ok = zip->getCurrentFileInfo(&info); } else { *ok = true; info.compressedSize = 0; info.crc = 0; info.diskNumberStart = 0; info.externalAttr = 0; info.flags = 0; info.internalAttr = 0; info.method = 0; info.uncompressedSize = 0; info.versionCreated = info.versionNeeded = 0; } info.name = relativeName; return info; } static void QuaZipDir_convertInfoList(const QList &from, QList &to) { to = from; } static void QuaZipDir_convertInfoList(const QList &from, QStringList &to) { to.clear(); for (QList::const_iterator i = from.constBegin(); i != from.constEnd(); ++i) { to.append(i->name); } } static void QuaZipDir_convertInfoList(const QList &from, QList &to) { to.clear(); for (QList::const_iterator i = from.constBegin(); i != from.constEnd(); ++i) { QuaZipFileInfo info32; i->toQuaZipFileInfo(info32); to.append(info32); } } /// \cond internal /** An utility class to restore the current file. */ class QuaZipDirRestoreCurrent { public: inline QuaZipDirRestoreCurrent(QuaZip *zip): zip(zip), currentFile(zip->getCurrentFileName()) {} inline ~QuaZipDirRestoreCurrent() { zip->setCurrentFile(currentFile); } private: QuaZip *zip; QString currentFile; }; /// \endcond /// \cond internal class QuaZipDirComparator { private: QDir::SortFlags sort; static QString getExtension(const QString &name); int compareStrings(const QString &string1, const QString &string2); public: inline QuaZipDirComparator(QDir::SortFlags sort): sort(sort) {} bool operator()(const QuaZipFileInfo64 &info1, const QuaZipFileInfo64 &info2); }; QString QuaZipDirComparator::getExtension(const QString &name) { if (name.endsWith(QLatin1String(".")) || name.indexOf(QLatin1String("."), 1) == -1) { return QLatin1String(""); } else { return name.mid(name.lastIndexOf(QLatin1String(".")) + 1); } } int QuaZipDirComparator::compareStrings(const QString &string1, const QString &string2) { if (sort & QDir::LocaleAware) { if (sort & QDir::IgnoreCase) { return string1.toLower().localeAwareCompare(string2.toLower()); } else { return string1.localeAwareCompare(string2); } } else { return string1.compare(string2, (sort & QDir::IgnoreCase) ? Qt::CaseInsensitive : Qt::CaseSensitive); } } bool QuaZipDirComparator::operator()(const QuaZipFileInfo64 &info1, const QuaZipFileInfo64 &info2) { QDir::SortFlags order = sort & (QDir::Name | QDir::Time | QDir::Size | QDir::Type); if ((sort & QDir::DirsFirst) == QDir::DirsFirst || (sort & QDir::DirsLast) == QDir::DirsLast) { if (info1.name.endsWith(QLatin1String("/")) && !info2.name.endsWith(QLatin1String("/"))) return (sort & QDir::DirsFirst) == QDir::DirsFirst; else if (!info1.name.endsWith(QLatin1String("/")) && info2.name.endsWith(QLatin1String("/"))) return (sort & QDir::DirsLast) == QDir::DirsLast; } bool result; int extDiff; switch (order) { case QDir::Name: result = compareStrings(info1.name, info2.name) < 0; break; case QDir::Type: extDiff = compareStrings(getExtension(info1.name), getExtension(info2.name)); if (extDiff == 0) { result = compareStrings(info1.name, info2.name) < 0; } else { result = extDiff < 0; } break; case QDir::Size: if (info1.uncompressedSize == info2.uncompressedSize) { result = compareStrings(info1.name, info2.name) < 0; } else { result = info1.uncompressedSize < info2.uncompressedSize; } break; case QDir::Time: if (info1.dateTime == info2.dateTime) { result = compareStrings(info1.name, info2.name) < 0; } else { result = info1.dateTime < info2.dateTime; } break; default: qWarning("QuaZipDirComparator(): Invalid sort mode 0x%2X", static_cast(sort)); return false; } return (sort & QDir::Reversed) ? !result : result; } template bool QuaZipDirPrivate::entryInfoList(QStringList nameFilters, QDir::Filters filter, QDir::SortFlags sort, TFileInfoList &result) const { QString basePath = simplePath(); if (!basePath.isEmpty()) basePath += QLatin1String("/"); int baseLength = basePath.length(); result.clear(); QuaZipDirRestoreCurrent saveCurrent(zip); if (!zip->goToFirstFile()) { return zip->getZipError() == UNZ_OK; } QDir::Filters fltr = filter; if (fltr == QDir::NoFilter) fltr = this->filter; if (fltr == QDir::NoFilter) fltr = QDir::AllEntries; QStringList nmfltr = nameFilters; if (nmfltr.isEmpty()) nmfltr = this->nameFilters; QSet dirsFound; QList list; do { QString name = zip->getCurrentFileName(); if (!name.startsWith(basePath)) continue; QString relativeName = name.mid(baseLength); if (relativeName.isEmpty()) continue; bool isDir = false; bool isReal = true; if (relativeName.contains(QLatin1String("/"))) { int indexOfSlash = relativeName.indexOf(QLatin1String("/")); // something like "subdir/" isReal = indexOfSlash == relativeName.length() - 1; relativeName = relativeName.left(indexOfSlash + 1); if (dirsFound.contains(relativeName)) continue; isDir = true; } dirsFound.insert(relativeName); if ((fltr & QDir::Dirs) == 0 && isDir) continue; if ((fltr & QDir::Files) == 0 && !isDir) continue; if (!nmfltr.isEmpty() && !QDir::match(nmfltr, relativeName)) continue; bool ok; QuaZipFileInfo64 info = QuaZipDir_getFileInfo(zip, &ok, relativeName, isReal); if (!ok) { return false; } list.append(info); } while (zip->goToNextFile()); QDir::SortFlags srt = sort; if (srt == QDir::NoSort) srt = sorting; #ifdef QUAZIP_QUAZIPDIR_DEBUG qDebug("QuaZipDirPrivate::entryInfoList(): before sort:"); foreach (QuaZipFileInfo64 info, list) { qDebug("%s\t%s", info.name.toUtf8().constData(), info.dateTime.toString(Qt::ISODate).toUtf8().constData()); } #endif if (srt != QDir::NoSort && (srt & QDir::Unsorted) != QDir::Unsorted) { if (QuaZip::convertCaseSensitivity(caseSensitivity) == Qt::CaseInsensitive) srt |= QDir::IgnoreCase; QuaZipDirComparator lessThan(srt); #if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)) std::sort(list.begin(), list.end(), lessThan); #else qSort(list.begin(), list.end(), lessThan); #endif } QuaZipDir_convertInfoList(list, result); return true; } /// \endcond QList QuaZipDir::entryInfoList(const QStringList &nameFilters, QDir::Filters filters, QDir::SortFlags sort) const { QList result; if (d->entryInfoList(nameFilters, filters, sort, result)) return result; else return QList(); } QList QuaZipDir::entryInfoList(QDir::Filters filters, QDir::SortFlags sort) const { return entryInfoList(QStringList(), filters, sort); } QList QuaZipDir::entryInfoList64(const QStringList &nameFilters, QDir::Filters filters, QDir::SortFlags sort) const { QList result; if (d->entryInfoList(nameFilters, filters, sort, result)) return result; else return QList(); } QList QuaZipDir::entryInfoList64(QDir::Filters filters, QDir::SortFlags sort) const { return entryInfoList64(QStringList(), filters, sort); } QStringList QuaZipDir::entryList(const QStringList &nameFilters, QDir::Filters filters, QDir::SortFlags sort) const { QStringList result; if (d->entryInfoList(nameFilters, filters, sort, result)) return result; else return QStringList(); } QStringList QuaZipDir::entryList(QDir::Filters filters, QDir::SortFlags sort) const { return entryList(QStringList(), filters, sort); } bool QuaZipDir::exists(const QString &filePath) const { if (filePath == QLatin1String("/") || filePath.isEmpty()) return true; QString fileName = filePath; if (fileName.endsWith(QLatin1String("/"))) fileName.chop(1); if (fileName.contains(QLatin1String("/"))) { QFileInfo fileInfo(fileName); #ifdef QUAZIP_QUAZIPDIR_DEBUG qDebug("QuaZipDir::exists(): fileName=%s, fileInfo.fileName()=%s, " "fileInfo.path()=%s", fileName.toUtf8().constData(), fileInfo.fileName().toUtf8().constData(), fileInfo.path().toUtf8().constData()); #endif QuaZipDir dir(*this); return dir.cd(fileInfo.path()) && dir.exists(fileInfo.fileName()); } else { if (fileName == QLatin1String("..")) { return !isRoot(); } else if (fileName == QLatin1String(".")) { return true; } else { QStringList entries = entryList(QDir::AllEntries, QDir::NoSort); #ifdef QUAZIP_QUAZIPDIR_DEBUG qDebug("QuaZipDir::exists(): looking for %s", fileName.toUtf8().constData()); for (QStringList::const_iterator i = entries.constBegin(); i != entries.constEnd(); ++i) { qDebug("QuaZipDir::exists(): entry: %s", i->toUtf8().constData()); } #endif Qt::CaseSensitivity cs = QuaZip::convertCaseSensitivity( d->caseSensitivity); if (filePath.endsWith(QLatin1String("/"))) { return entries.contains(filePath, cs); } else { return entries.contains(fileName, cs) || entries.contains(fileName + QLatin1String("/"), cs); } } } } bool QuaZipDir::exists() const { return QuaZipDir(d->zip).exists(d->dir); } QString QuaZipDir::filePath(const QString &fileName) const { return QDir(d->dir).filePath(fileName); } QDir::Filters QuaZipDir::filter() { return d->filter; } bool QuaZipDir::isRoot() const { return d->simplePath().isEmpty(); } QStringList QuaZipDir::nameFilters() const { return d->nameFilters; } QString QuaZipDir::path() const { return d->dir; } QString QuaZipDir::relativeFilePath(const QString &fileName) const { return QDir(QLatin1String("/") + d->dir).relativeFilePath(fileName); } void QuaZipDir::setCaseSensitivity(QuaZip::CaseSensitivity caseSensitivity) { d->caseSensitivity = caseSensitivity; } void QuaZipDir::setFilter(QDir::Filters filters) { d->filter = filters; } void QuaZipDir::setNameFilters(const QStringList &nameFilters) { d->nameFilters = nameFilters; } void QuaZipDir::setPath(const QString &path) { QString newDir = path; if (newDir == QLatin1String("/")) { d->dir = QLatin1String(""); } else { if (newDir.endsWith(QLatin1String("/"))) newDir.chop(1); if (newDir.startsWith(QLatin1String("/"))) newDir = newDir.mid(1); d->dir = newDir; } } void QuaZipDir::setSorting(QDir::SortFlags sort) { d->sorting = sort; } QDir::SortFlags QuaZipDir::sorting() const { return d->sorting; } quazip-0.9.1/quazip/quazipdir.h000066400000000000000000000202011366246114300165250ustar00rootroot00000000000000#ifndef QUAZIP_QUAZIPDIR_H #define QUAZIP_QUAZIPDIR_H /* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ class QuaZipDirPrivate; #include "quazip.h" #include "quazipfileinfo.h" #include #include #include /// Provides ZIP archive navigation. /** * This class is modelled after QDir, and is designed to provide similar * features for ZIP archives. * * The only significant difference from QDir is that the root path is not * '/', but an empty string since that's how the file paths are stored in * the archive. However, QuaZipDir understands the paths starting with * '/'. It is important in a few places: * * - In the cd() function. * - In the constructor. * - In the exists() function. * - In the relativePath() function. * * Note that since ZIP uses '/' on all platforms, the '\' separator is * not supported. */ class QUAZIP_EXPORT QuaZipDir { private: QSharedDataPointer d; public: /// The copy constructor. QuaZipDir(const QuaZipDir &that); /// Constructs a QuaZipDir instance pointing to the specified directory. /** If \a dir is not specified, points to the root of the archive. The same happens if the \a dir is "/". */ QuaZipDir(QuaZip *zip, const QString &dir = QString()); /// Destructor. ~QuaZipDir(); /// The assignment operator. bool operator==(const QuaZipDir &that); /// operator!= /** \return \c true if either this and \a that use different QuaZip instances or if they point to different directories. */ inline bool operator!=(const QuaZipDir &that) {return !operator==(that);} /// operator== /** \return \c true if both this and \a that use the same QuaZip instance and point to the same directory. */ QuaZipDir& operator=(const QuaZipDir &that); /// Returns the name of the entry at the specified position. QString operator[](int pos) const; /// Returns the current case sensitivity mode. QuaZip::CaseSensitivity caseSensitivity() const; /// Changes the 'current' directory. /** * If the path starts with '/', it is interpreted as an absolute * path from the root of the archive. Otherwise, it is interpreted * as a path relative to the current directory as was set by the * previous cd() or the constructor. * * Note that the subsequent path() call will not return a path * starting with '/' in all cases. */ bool cd(const QString &dirName); /// Goes up. bool cdUp(); /// Returns the number of entries in the directory. uint count() const; /// Returns the current directory name. /** The name doesn't include the path. */ QString dirName() const; /// Returns the list of the entries in the directory. /** \param nameFilters The list of file patterns to list, uses the same syntax as QDir. \param filters The entry type filters, only Files and Dirs are accepted. \param sort Sorting mode. */ QList entryInfoList(const QStringList &nameFilters, QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const; /// Returns the list of the entries in the directory. /** \overload The same as entryInfoList(QStringList(), filters, sort). */ QList entryInfoList(QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const; /// Returns the list of the entries in the directory with zip64 support. /** \param nameFilters The list of file patterns to list, uses the same syntax as QDir. \param filters The entry type filters, only Files and Dirs are accepted. \param sort Sorting mode. */ QList entryInfoList64(const QStringList &nameFilters, QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const; /// Returns the list of the entries in the directory with zip64 support. /** \overload The same as entryInfoList64(QStringList(), filters, sort). */ QList entryInfoList64(QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const; /// Returns the list of the entry names in the directory. /** The same as entryInfoList(nameFilters, filters, sort), but only returns entry names. */ QStringList entryList(const QStringList &nameFilters, QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const; /// Returns the list of the entry names in the directory. /** \overload The same as entryList(QStringList(), filters, sort). */ QStringList entryList(QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const; /// Returns \c true if the entry with the specified name exists. /** The ".." is considered to exist if the current directory is not root. The "." and "/" are considered to always exist. Paths starting with "/" are relative to the archive root, other paths are relative to the current dir. */ bool exists(const QString &fileName) const; /// Return \c true if the directory pointed by this QuaZipDir exists. bool exists() const; /// Returns the full path to the specified file. /** Doesn't check if the file actually exists. */ QString filePath(const QString &fileName) const; /// Returns the default filter. QDir::Filters filter(); /// Returns if the QuaZipDir points to the root of the archive. /** Not that the root path is the empty string, not '/'. */ bool isRoot() const; /// Return the default name filter. QStringList nameFilters() const; /// Returns the path to the current dir. /** The path never starts with '/', and the root path is an empty string. */ QString path() const; /// Returns the path to the specified file relative to the current dir. /** * This function is mostly useless, provided only for the sake of * completeness. * * @param fileName The path to the file, should start with "/" * if relative to the archive root. * @return Path relative to the current dir. */ QString relativeFilePath(const QString &fileName) const; /// Sets the default case sensitivity mode. void setCaseSensitivity(QuaZip::CaseSensitivity caseSensitivity); /// Sets the default filter. void setFilter(QDir::Filters filters); /// Sets the default name filter. void setNameFilters(const QStringList &nameFilters); /// Goes to the specified path. /** The difference from cd() is that this function never checks if the path actually exists and doesn't use relative paths, so it's possible to go to the root directory with setPath(""). Note that this function still chops the trailing and/or leading '/' and treats a single '/' as the root path (path() will still return an empty string). */ void setPath(const QString &path); /// Sets the default sorting mode. void setSorting(QDir::SortFlags sort); /// Returns the default sorting mode. QDir::SortFlags sorting() const; }; #endif // QUAZIP_QUAZIPDIR_H quazip-0.9.1/quazip/quazipfile.cpp000066400000000000000000000367211366246114300172370ustar00rootroot00000000000000/* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant, see quazip/(un)zip.h files for details, basically it's zlib license. **/ #include "quazipfile.h" #include "quazipfileinfo.h" using namespace std; #define QUAZIP_VERSION_MADE_BY 0x1Eu /// The implementation class for QuaZip. /** \internal This class contains all the private stuff for the QuaZipFile class, thus allowing to preserve binary compatibility between releases, the technique known as the Pimpl (private implementation) idiom. */ class QuaZipFilePrivate { friend class QuaZipFile; private: Q_DISABLE_COPY(QuaZipFilePrivate) /// The pointer to the associated QuaZipFile instance. QuaZipFile *q; /// The QuaZip object to work with. QuaZip *zip; /// The file name. QString fileName; /// Case sensitivity mode. QuaZip::CaseSensitivity caseSensitivity; /// Whether this file is opened in the raw mode. bool raw; /// Write position to keep track of. /** QIODevice::pos() is broken for non-seekable devices, so we need our own position. */ qint64 writePos; /// Uncompressed size to write along with a raw file. quint64 uncompressedSize; /// CRC to write along with a raw file. quint32 crc; /// Whether \ref zip points to an internal QuaZip instance. /** This is true if the archive was opened by name, rather than by supplying an existing QuaZip instance. */ bool internal; /// The last error. int zipError; /// Resets \ref zipError. inline void resetZipError() const {setZipError(UNZ_OK);} /// Sets the zip error. /** This function is marked as const although it changes one field. This allows to call it from const functions that don't change anything by themselves. */ void setZipError(int zipError) const; /// The constructor for the corresponding QuaZipFile constructor. inline QuaZipFilePrivate(QuaZipFile *q): q(q), zip(NULL), caseSensitivity(QuaZip::csDefault), raw(false), writePos(0), uncompressedSize(0), crc(0), internal(true), zipError(UNZ_OK) {} /// The constructor for the corresponding QuaZipFile constructor. inline QuaZipFilePrivate(QuaZipFile *q, const QString &zipName): q(q), caseSensitivity(QuaZip::csDefault), raw(false), writePos(0), uncompressedSize(0), crc(0), internal(true), zipError(UNZ_OK) { zip=new QuaZip(zipName); } /// The constructor for the corresponding QuaZipFile constructor. inline QuaZipFilePrivate(QuaZipFile *q, const QString &zipName, const QString &fileName, QuaZip::CaseSensitivity cs): q(q), raw(false), writePos(0), uncompressedSize(0), crc(0), internal(true), zipError(UNZ_OK) { zip=new QuaZip(zipName); this->fileName=fileName; if (this->fileName.startsWith(QLatin1String("/"))) this->fileName = this->fileName.mid(1); this->caseSensitivity=cs; } /// The constructor for the QuaZipFile constructor accepting a file name. inline QuaZipFilePrivate(QuaZipFile *q, QuaZip *zip): q(q), zip(zip), raw(false), writePos(0), uncompressedSize(0), crc(0), internal(false), zipError(UNZ_OK) {} /// The destructor. inline ~QuaZipFilePrivate() { if (internal) delete zip; } }; QuaZipFile::QuaZipFile(): p(new QuaZipFilePrivate(this)) { } QuaZipFile::QuaZipFile(QObject *parent): QIODevice(parent), p(new QuaZipFilePrivate(this)) { } QuaZipFile::QuaZipFile(const QString& zipName, QObject *parent): QIODevice(parent), p(new QuaZipFilePrivate(this, zipName)) { } QuaZipFile::QuaZipFile(const QString& zipName, const QString& fileName, QuaZip::CaseSensitivity cs, QObject *parent): QIODevice(parent), p(new QuaZipFilePrivate(this, zipName, fileName, cs)) { } QuaZipFile::QuaZipFile(QuaZip *zip, QObject *parent): QIODevice(parent), p(new QuaZipFilePrivate(this, zip)) { } QuaZipFile::~QuaZipFile() { if (isOpen()) close(); delete p; } QString QuaZipFile::getZipName() const { return p->zip==NULL ? QString() : p->zip->getZipName(); } QuaZip *QuaZipFile::getZip() const { return p->internal ? NULL : p->zip; } QString QuaZipFile::getActualFileName()const { p->setZipError(UNZ_OK); if (p->zip == NULL || (openMode() & WriteOnly)) return QString(); QString name=p->zip->getCurrentFileName(); if(name.isNull()) p->setZipError(p->zip->getZipError()); return name; } void QuaZipFile::setZipName(const QString& zipName) { if(isOpen()) { qWarning("QuaZipFile::setZipName(): file is already open - can not set ZIP name"); return; } if(p->zip!=NULL && p->internal) delete p->zip; p->zip=new QuaZip(zipName); p->internal=true; } void QuaZipFile::setZip(QuaZip *zip) { if(isOpen()) { qWarning("QuaZipFile::setZip(): file is already open - can not set ZIP"); return; } if(p->zip!=NULL && p->internal) delete p->zip; p->zip=zip; p->fileName=QString(); p->internal=false; } void QuaZipFile::setFileName(const QString& fileName, QuaZip::CaseSensitivity cs) { if(p->zip==NULL) { qWarning("QuaZipFile::setFileName(): call setZipName() first"); return; } if(!p->internal) { qWarning("QuaZipFile::setFileName(): should not be used when not using internal QuaZip"); return; } if(isOpen()) { qWarning("QuaZipFile::setFileName(): can not set file name for already opened file"); return; } p->fileName=fileName; if (p->fileName.startsWith(QLatin1String("/"))) p->fileName = p->fileName.mid(1); p->caseSensitivity=cs; } void QuaZipFilePrivate::setZipError(int zipError) const { QuaZipFilePrivate *fakeThis = const_cast(this); // non-const fakeThis->zipError=zipError; if(zipError==UNZ_OK) q->setErrorString(QString()); else q->setErrorString(QuaZipFile::tr("ZIP/UNZIP API error %1").arg(zipError)); } bool QuaZipFile::open(OpenMode mode) { return open(mode, NULL); } bool QuaZipFile::open(OpenMode mode, int *method, int *level, bool raw, const char *password) { p->resetZipError(); if(isOpen()) { qWarning("QuaZipFile::open(): already opened"); return false; } if(mode&Unbuffered) { qWarning("QuaZipFile::open(): Unbuffered mode is not supported"); return false; } if((mode&ReadOnly)&&!(mode&WriteOnly)) { if(p->internal) { if(!p->zip->open(QuaZip::mdUnzip)) { p->setZipError(p->zip->getZipError()); return false; } if(!p->zip->setCurrentFile(p->fileName, p->caseSensitivity)) { p->setZipError(p->zip->getZipError()); p->zip->close(); return false; } } else { if(p->zip==NULL) { qWarning("QuaZipFile::open(): zip is NULL"); return false; } if(p->zip->getMode()!=QuaZip::mdUnzip) { qWarning("QuaZipFile::open(): file open mode %d incompatible with ZIP open mode %d", (int)mode, (int)p->zip->getMode()); return false; } if(!p->zip->hasCurrentFile()) { qWarning("QuaZipFile::open(): zip does not have current file"); return false; } } p->setZipError(unzOpenCurrentFile3(p->zip->getUnzFile(), method, level, (int)raw, password)); if(p->zipError==UNZ_OK) { setOpenMode(mode); p->raw=raw; return true; } else return false; } qWarning("QuaZipFile::open(): open mode %d not supported by this function", (int)mode); return false; } bool QuaZipFile::open(OpenMode mode, const QuaZipNewInfo& info, const char *password, quint32 crc, int method, int level, bool raw, int windowBits, int memLevel, int strategy) { zip_fileinfo info_z; p->resetZipError(); if(isOpen()) { qWarning("QuaZipFile::open(): already opened"); return false; } if((mode&WriteOnly)&&!(mode&ReadOnly)) { if(p->internal) { qWarning("QuaZipFile::open(): write mode is incompatible with internal QuaZip approach"); return false; } if(p->zip==NULL) { qWarning("QuaZipFile::open(): zip is NULL"); return false; } if(p->zip->getMode()!=QuaZip::mdCreate&&p->zip->getMode()!=QuaZip::mdAppend&&p->zip->getMode()!=QuaZip::mdAdd) { qWarning("QuaZipFile::open(): file open mode %d incompatible with ZIP open mode %d", (int)mode, (int)p->zip->getMode()); return false; } info_z.tmz_date.tm_year=info.dateTime.date().year(); info_z.tmz_date.tm_mon=info.dateTime.date().month() - 1; info_z.tmz_date.tm_mday=info.dateTime.date().day(); info_z.tmz_date.tm_hour=info.dateTime.time().hour(); info_z.tmz_date.tm_min=info.dateTime.time().minute(); info_z.tmz_date.tm_sec=info.dateTime.time().second(); info_z.dosDate = 0; info_z.internal_fa=(uLong)info.internalAttr; info_z.external_fa=(uLong)info.externalAttr; if (p->zip->isDataDescriptorWritingEnabled()) zipSetFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR); else zipClearFlags(p->zip->getZipFile(), ZIP_WRITE_DATA_DESCRIPTOR); p->setZipError(zipOpenNewFileInZip4_64(p->zip->getZipFile(), p->zip->isUtf8Enabled() ? info.name.toUtf8().constData() : p->zip->getFileNameCodec()->fromUnicode(info.name).constData(), &info_z, info.extraLocal.constData(), info.extraLocal.length(), info.extraGlobal.constData(), info.extraGlobal.length(), p->zip->isUtf8Enabled() ? info.comment.toUtf8().constData() : p->zip->getCommentCodec()->fromUnicode(info.comment).constData(), method, level, (int)raw, windowBits, memLevel, strategy, password, (uLong)crc, (p->zip->getOsCode() << 8) | QUAZIP_VERSION_MADE_BY, 0, p->zip->isZip64Enabled())); if(p->zipError==UNZ_OK) { p->writePos=0; setOpenMode(mode); p->raw=raw; if(raw) { p->crc=crc; p->uncompressedSize=info.uncompressedSize; } return true; } else return false; } qWarning("QuaZipFile::open(): open mode %d not supported by this function", (int)mode); return false; } bool QuaZipFile::isSequential()const { return true; } qint64 QuaZipFile::pos()const { if(p->zip==NULL) { qWarning("QuaZipFile::pos(): call setZipName() or setZip() first"); return -1; } if(!isOpen()) { qWarning("QuaZipFile::pos(): file is not open"); return -1; } if(openMode()&ReadOnly) // QIODevice::pos() is broken for sequential devices, // but thankfully bytesAvailable() returns the number of // bytes buffered, so we know how far ahead we are. return unztell64(p->zip->getUnzFile()) - QIODevice::bytesAvailable(); else return p->writePos; } bool QuaZipFile::atEnd()const { if(p->zip==NULL) { qWarning("QuaZipFile::atEnd(): call setZipName() or setZip() first"); return false; } if(!isOpen()) { qWarning("QuaZipFile::atEnd(): file is not open"); return false; } if(openMode()&ReadOnly) // the same problem as with pos() return QIODevice::bytesAvailable() == 0 && unzeof(p->zip->getUnzFile())==1; else return true; } qint64 QuaZipFile::size()const { if(!isOpen()) { qWarning("QuaZipFile::atEnd(): file is not open"); return -1; } if(openMode()&ReadOnly) return p->raw?csize():usize(); else return p->writePos; } qint64 QuaZipFile::csize()const { unz_file_info64 info_z; p->setZipError(UNZ_OK); if(p->zip==NULL||p->zip->getMode()!=QuaZip::mdUnzip) return -1; p->setZipError(unzGetCurrentFileInfo64(p->zip->getUnzFile(), &info_z, NULL, 0, NULL, 0, NULL, 0)); if(p->zipError!=UNZ_OK) return -1; return info_z.compressed_size; } qint64 QuaZipFile::usize()const { unz_file_info64 info_z; p->setZipError(UNZ_OK); if(p->zip==NULL||p->zip->getMode()!=QuaZip::mdUnzip) return -1; p->setZipError(unzGetCurrentFileInfo64(p->zip->getUnzFile(), &info_z, NULL, 0, NULL, 0, NULL, 0)); if(p->zipError!=UNZ_OK) return -1; return info_z.uncompressed_size; } bool QuaZipFile::getFileInfo(QuaZipFileInfo *info) { QuaZipFileInfo64 info64; if (getFileInfo(&info64)) { info64.toQuaZipFileInfo(*info); return true; } else { return false; } } bool QuaZipFile::getFileInfo(QuaZipFileInfo64 *info) { if(p->zip==NULL||p->zip->getMode()!=QuaZip::mdUnzip) return false; p->zip->getCurrentFileInfo(info); p->setZipError(p->zip->getZipError()); return p->zipError==UNZ_OK; } void QuaZipFile::close() { p->resetZipError(); if(p->zip==NULL||!p->zip->isOpen()) return; if(!isOpen()) { qWarning("QuaZipFile::close(): file isn't open"); return; } if(openMode()&ReadOnly) p->setZipError(unzCloseCurrentFile(p->zip->getUnzFile())); else if(openMode()&WriteOnly) if(isRaw()) p->setZipError(zipCloseFileInZipRaw64(p->zip->getZipFile(), p->uncompressedSize, p->crc)); else p->setZipError(zipCloseFileInZip(p->zip->getZipFile())); else { qWarning("Wrong open mode: %d", (int)openMode()); return; } if(p->zipError==UNZ_OK) setOpenMode(QIODevice::NotOpen); else return; if(p->internal) { p->zip->close(); p->setZipError(p->zip->getZipError()); } } qint64 QuaZipFile::readData(char *data, qint64 maxSize) { p->setZipError(UNZ_OK); qint64 bytesRead=unzReadCurrentFile(p->zip->getUnzFile(), data, (unsigned)maxSize); if (bytesRead < 0) { p->setZipError((int) bytesRead); return -1; } return bytesRead; } qint64 QuaZipFile::writeData(const char* data, qint64 maxSize) { p->setZipError(ZIP_OK); p->setZipError(zipWriteInFileInZip(p->zip->getZipFile(), data, (uint)maxSize)); if(p->zipError!=ZIP_OK) return -1; else { p->writePos+=maxSize; return maxSize; } } QString QuaZipFile::getFileName() const { return p->fileName; } QuaZip::CaseSensitivity QuaZipFile::getCaseSensitivity() const { return p->caseSensitivity; } bool QuaZipFile::isRaw() const { return p->raw; } int QuaZipFile::getZipError() const { return p->zipError; } qint64 QuaZipFile::bytesAvailable() const { return size() - pos(); } QByteArray QuaZipFile::getLocalExtraField() { int size = unzGetLocalExtrafield(p->zip->getUnzFile(), NULL, 0); QByteArray extra(size, '\0'); int err = unzGetLocalExtrafield(p->zip->getUnzFile(), extra.data(), static_cast(extra.size())); if (err < 0) { p->setZipError(err); return QByteArray(); } return extra; } QDateTime QuaZipFile::getExtModTime() { return QuaZipFileInfo64::getExtTime(getLocalExtraField(), QUAZIP_EXTRA_EXT_MOD_TIME_FLAG); } QDateTime QuaZipFile::getExtAcTime() { return QuaZipFileInfo64::getExtTime(getLocalExtraField(), QUAZIP_EXTRA_EXT_AC_TIME_FLAG); } QDateTime QuaZipFile::getExtCrTime() { return QuaZipFileInfo64::getExtTime(getLocalExtraField(), QUAZIP_EXTRA_EXT_CR_TIME_FLAG); } quazip-0.9.1/quazip/quazipfile.h000066400000000000000000000527601366246114300167050ustar00rootroot00000000000000#ifndef QUA_ZIPFILE_H #define QUA_ZIPFILE_H /* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant, see quazip/(un)zip.h files for details, basically it's zlib license. **/ #include #include "quazip_global.h" #include "quazip.h" #include "quazipnewinfo.h" class QuaZipFilePrivate; /// A file inside ZIP archive. /** \class QuaZipFile quazipfile.h * This is the most interesting class. Not only it provides C++ * interface to the ZIP/UNZIP package, but also integrates it with Qt by * subclassing QIODevice. This makes possible to access files inside ZIP * archive using QTextStream or QDataStream, for example. Actually, this * is the main purpose of the whole QuaZIP library. * * You can either use existing QuaZip instance to create instance of * this class or pass ZIP archive file name to this class, in which case * it will create internal QuaZip object. See constructors' descriptions * for details. Writing is only possible with the existing instance. * * Note that due to the underlying library's limitation it is not * possible to use multiple QuaZipFile instances to open several files * in the same archive at the same time. If you need to write to * multiple files in parallel, then you should write to temporary files * first, then pack them all at once when you have finished writing. If * you need to read multiple files inside the same archive in parallel, * you should extract them all into a temporary directory first. * * \section quazipfile-sequential Sequential or random-access? * * At the first thought, QuaZipFile has fixed size, the start and the * end and should be therefore considered random-access device. But * there is one major obstacle to making it random-access: ZIP/UNZIP API * does not support seek() operation and the only way to implement it is * through reopening the file and re-reading to the required position, * but this is prohibitively slow. * * Therefore, QuaZipFile is considered to be a sequential device. This * has advantage of availability of the ungetChar() operation (QIODevice * does not implement it properly for non-sequential devices unless they * support seek()). Disadvantage is a somewhat strange behaviour of the * size() and pos() functions. This should be kept in mind while using * this class. * **/ class QUAZIP_EXPORT QuaZipFile: public QIODevice { friend class QuaZipFilePrivate; Q_OBJECT private: QuaZipFilePrivate *p; // these are not supported nor implemented QuaZipFile(const QuaZipFile& that); QuaZipFile& operator=(const QuaZipFile& that); protected: /// Implementation of the QIODevice::readData(). qint64 readData(char *data, qint64 maxSize); /// Implementation of the QIODevice::writeData(). qint64 writeData(const char *data, qint64 maxSize); public: /// Constructs a QuaZipFile instance. /** You should use setZipName() and setFileName() or setZip() before * trying to call open() on the constructed object. **/ QuaZipFile(); /// Constructs a QuaZipFile instance. /** \a parent argument specifies this object's parent object. * * You should use setZipName() and setFileName() or setZip() before * trying to call open() on the constructed object. **/ QuaZipFile(QObject *parent); /// Constructs a QuaZipFile instance. /** \a parent argument specifies this object's parent object and \a * zipName specifies ZIP archive file name. * * You should use setFileName() before trying to call open() on the * constructed object. * * QuaZipFile constructed by this constructor can be used for read * only access. Use QuaZipFile(QuaZip*,QObject*) for writing. **/ QuaZipFile(const QString& zipName, QObject *parent =NULL); /// Constructs a QuaZipFile instance. /** \a parent argument specifies this object's parent object, \a * zipName specifies ZIP archive file name and \a fileName and \a cs * specify a name of the file to open inside archive. * * QuaZipFile constructed by this constructor can be used for read * only access. Use QuaZipFile(QuaZip*,QObject*) for writing. * * \sa QuaZip::setCurrentFile() **/ QuaZipFile(const QString& zipName, const QString& fileName, QuaZip::CaseSensitivity cs =QuaZip::csDefault, QObject *parent =NULL); /// Constructs a QuaZipFile instance. /** \a parent argument specifies this object's parent object. * * \a zip is the pointer to the existing QuaZip object. This * QuaZipFile object then can be used to read current file in the * \a zip or to write to the file inside it. * * \warning Using this constructor for reading current file can be * tricky. Let's take the following example: * \code * QuaZip zip("archive.zip"); * zip.open(QuaZip::mdUnzip); * zip.setCurrentFile("file-in-archive"); * QuaZipFile file(&zip); * file.open(QIODevice::ReadOnly); * // ok, now we can read from the file * file.read(somewhere, some); * zip.setCurrentFile("another-file-in-archive"); // oops... * QuaZipFile anotherFile(&zip); * anotherFile.open(QIODevice::ReadOnly); * anotherFile.read(somewhere, some); // this is still ok... * file.read(somewhere, some); // and this is NOT * \endcode * So, what exactly happens here? When we change current file in the * \c zip archive, \c file that references it becomes invalid * (actually, as far as I understand ZIP/UNZIP sources, it becomes * closed, but QuaZipFile has no means to detect it). * * Summary: do not close \c zip object or change its current file as * long as QuaZipFile is open. Even better - use another constructors * which create internal QuaZip instances, one per object, and * therefore do not cause unnecessary trouble. This constructor may * be useful, though, if you already have a QuaZip instance and do * not want to access several files at once. Good example: * \code * QuaZip zip("archive.zip"); * zip.open(QuaZip::mdUnzip); * // first, we need some information about archive itself * QByteArray comment=zip.getComment(); * // and now we are going to access files inside it * QuaZipFile file(&zip); * for(bool more=zip.goToFirstFile(); more; more=zip.goToNextFile()) { * file.open(QIODevice::ReadOnly); * // do something cool with file here * file.close(); // do not forget to close! * } * zip.close(); * \endcode **/ QuaZipFile(QuaZip *zip, QObject *parent =NULL); /// Destroys a QuaZipFile instance. /** Closes file if open, destructs internal QuaZip object (if it * exists and \em is internal, of course). **/ virtual ~QuaZipFile(); /// Returns the ZIP archive file name. /** If this object was created by passing QuaZip pointer to the * constructor, this function will return that QuaZip's file name * (or null string if that object does not have file name yet). * * Otherwise, returns associated ZIP archive file name or null * string if there are no name set yet. * * \sa setZipName() getFileName() **/ QString getZipName()const; /// Returns a pointer to the associated QuaZip object. /** Returns \c NULL if there is no associated QuaZip or it is * internal (so you will not mess with it). **/ QuaZip* getZip()const; /// Returns file name. /** This function returns file name you passed to this object either * by using * QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*) * or by calling setFileName(). Real name of the file may differ in * case if you used case-insensitivity. * * Returns null string if there is no file name set yet. This is the * case when this QuaZipFile operates on the existing QuaZip object * (constructor QuaZipFile(QuaZip*,QObject*) or setZip() was used). * * \sa getActualFileName **/ QString getFileName() const; /// Returns case sensitivity of the file name. /** This function returns case sensitivity argument you passed to * this object either by using * QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*) * or by calling setFileName(). * * Returns unpredictable value if getFileName() returns null string * (this is the case when you did not used setFileName() or * constructor above). * * \sa getFileName **/ QuaZip::CaseSensitivity getCaseSensitivity() const; /// Returns the actual file name in the archive. /** This is \em not a ZIP archive file name, but a name of file inside * archive. It is not necessary the same name that you have passed * to the * QuaZipFile(const QString&,const QString&,QuaZip::CaseSensitivity,QObject*), * setFileName() or QuaZip::setCurrentFile() - this is the real file * name inside archive, so it may differ in case if the file name * search was case-insensitive. * * Equivalent to calling getCurrentFileName() on the associated * QuaZip object. Returns null string if there is no associated * QuaZip object or if it does not have a current file yet. And this * is the case if you called setFileName() but did not open the * file yet. So this is perfectly fine: * \code * QuaZipFile file("somezip.zip"); * file.setFileName("somefile"); * QString name=file.getName(); // name=="somefile" * QString actual=file.getActualFileName(); // actual is null string * file.open(QIODevice::ReadOnly); * QString actual=file.getActualFileName(); // actual can be "SoMeFiLe" on Windows * \endcode * * \sa getZipName(), getFileName(), QuaZip::CaseSensitivity **/ QString getActualFileName()const; /// Sets the ZIP archive file name. /** Automatically creates internal QuaZip object and destroys * previously created internal QuaZip object, if any. * * Will do nothing if this file is already open. You must close() it * first. **/ void setZipName(const QString& zipName); /// Returns \c true if the file was opened in raw mode. /** If the file is not open, the returned value is undefined. * * \sa open(OpenMode,int*,int*,bool,const char*) **/ bool isRaw() const; /// Binds to the existing QuaZip instance. /** This function destroys internal QuaZip object, if any, and makes * this QuaZipFile to use current file in the \a zip object for any * further operations. See QuaZipFile(QuaZip*,QObject*) for the * possible pitfalls. * * Will do nothing if the file is currently open. You must close() * it first. **/ void setZip(QuaZip *zip); /// Sets the file name. /** Will do nothing if at least one of the following conditions is * met: * - ZIP name has not been set yet (getZipName() returns null * string). * - This QuaZipFile is associated with external QuaZip. In this * case you should call that QuaZip's setCurrentFile() function * instead! * - File is already open so setting the name is meaningless. * * \sa QuaZip::setCurrentFile **/ void setFileName(const QString& fileName, QuaZip::CaseSensitivity cs =QuaZip::csDefault); /// Opens a file for reading. /** Returns \c true on success, \c false otherwise. * Call getZipError() to get error code. * * \note Since ZIP/UNZIP API provides buffered reading only, * QuaZipFile does not support unbuffered reading. So do not pass * QIODevice::Unbuffered flag in \a mode, or open will fail. **/ virtual bool open(OpenMode mode); /// Opens a file for reading. /** \overload * Argument \a password specifies a password to decrypt the file. If * it is NULL then this function behaves just like open(OpenMode). **/ inline bool open(OpenMode mode, const char *password) {return open(mode, NULL, NULL, false, password);} /// Opens a file for reading. /** \overload * Argument \a password specifies a password to decrypt the file. * * An integers pointed by \a method and \a level will receive codes * of the compression method and level used. See unzip.h. * * If raw is \c true then no decompression is performed. * * \a method should not be \c NULL. \a level can be \c NULL if you * don't want to know the compression level. **/ bool open(OpenMode mode, int *method, int *level, bool raw, const char *password =NULL); /// Opens a file for writing. /** \a info argument specifies information about file. It should at * least specify a correct file name. Also, it is a good idea to * specify correct timestamp (by default, current time will be * used). See QuaZipNewInfo. * * The \a password argument specifies the password for crypting. Pass NULL * if you don't need any crypting. The \a crc argument was supposed * to be used for crypting too, but then it turned out that it's * false information, so you need to set it to 0 unless you want to * use the raw mode (see below). * * Arguments \a method and \a level specify compression method and * level. The only method supported is Z_DEFLATED, but you may also * specify 0 for no compression. If all of the files in the archive * use both method 0 and either level 0 is explicitly specified or * data descriptor writing is disabled with * QuaZip::setDataDescriptorWritingEnabled(), then the * resulting archive is supposed to be compatible with the 1.0 ZIP * format version, should you need that. Except for this, \a level * has no other effects with method 0. * * If \a raw is \c true, no compression is performed. In this case, * \a crc and uncompressedSize field of the \a info are required. * * Arguments \a windowBits, \a memLevel, \a strategy provide zlib * algorithms tuning. See deflateInit2() in zlib. **/ bool open(OpenMode mode, const QuaZipNewInfo& info, const char *password =NULL, quint32 crc =0, int method =Z_DEFLATED, int level =Z_DEFAULT_COMPRESSION, bool raw =false, int windowBits =-MAX_WBITS, int memLevel =DEF_MEM_LEVEL, int strategy =Z_DEFAULT_STRATEGY); /// Returns \c true, but \ref quazipfile-sequential "beware"! virtual bool isSequential()const; /// Returns current position in the file. /** Implementation of the QIODevice::pos(). When reading, this * function is a wrapper to the ZIP/UNZIP unztell(), therefore it is * unable to keep track of the ungetChar() calls (which is * non-virtual and therefore is dangerous to reimplement). So if you * are using ungetChar() feature of the QIODevice, this function * reports incorrect value until you get back characters which you * ungot. * * When writing, pos() returns number of bytes already written * (uncompressed unless you use raw mode). * * \note Although * \ref quazipfile-sequential "QuaZipFile is a sequential device" * and therefore pos() should always return zero, it does not, * because it would be misguiding. Keep this in mind. * * This function returns -1 if the file or archive is not open. * * Error code returned by getZipError() is not affected by this * function call. **/ virtual qint64 pos()const; /// Returns \c true if the end of file was reached. /** This function returns \c false in the case of error. This means * that you called this function on either not open file, or a file * in the not open archive or even on a QuaZipFile instance that * does not even have QuaZip instance associated. Do not do that * because there is no means to determine whether \c false is * returned because of error or because end of file was reached. * Well, on the other side you may interpret \c false return value * as "there is no file open to check for end of file and there is * no end of file therefore". * * When writing, this function always returns \c true (because you * are always writing to the end of file). * * Error code returned by getZipError() is not affected by this * function call. **/ virtual bool atEnd()const; /// Returns file size. /** This function returns csize() if the file is open for reading in * raw mode, usize() if it is open for reading in normal mode and * pos() if it is open for writing. * * Returns -1 on error, call getZipError() to get error code. * * \note This function returns file size despite that * \ref quazipfile-sequential "QuaZipFile is considered to be sequential device", * for which size() should return bytesAvailable() instead. But its * name would be very misguiding otherwise, so just keep in mind * this inconsistence. **/ virtual qint64 size()const; /// Returns compressed file size. /** Equivalent to calling getFileInfo() and then getting * compressedSize field, but more convenient and faster. * * File must be open for reading before calling this function. * * Returns -1 on error, call getZipError() to get error code. **/ qint64 csize()const; /// Returns uncompressed file size. /** Equivalent to calling getFileInfo() and then getting * uncompressedSize field, but more convenient and faster. See * getFileInfo() for a warning. * * File must be open for reading before calling this function. * * Returns -1 on error, call getZipError() to get error code. **/ qint64 usize()const; /// Gets information about current file. /** This function does the same thing as calling * QuaZip::getCurrentFileInfo() on the associated QuaZip object, * but you can not call getCurrentFileInfo() if the associated * QuaZip is internal (because you do not have access to it), while * you still can call this function in that case. * * File must be open for reading before calling this function. * * \return \c false in the case of an error. * * This function doesn't support zip64, but will still work fine on zip64 * archives if file sizes are below 4 GB, otherwise the values will be set * as if converted using QuaZipFileInfo64::toQuaZipFileInfo(). * * \sa getFileInfo(QuaZipFileInfo64*) **/ bool getFileInfo(QuaZipFileInfo *info); /// Gets information about current file with zip64 support. /** * @overload * * \sa getFileInfo(QuaZipFileInfo*) */ bool getFileInfo(QuaZipFileInfo64 *info); /// Closes the file. /** Call getZipError() to determine if the close was successful. **/ virtual void close(); /// Returns the error code returned by the last ZIP/UNZIP API call. int getZipError() const; /// Returns the number of bytes available for reading. virtual qint64 bytesAvailable() const; /// Returns the local extra field /** There are two (optional) local extra fields associated with a file. One is located in the central header and is available along with the rest of the file information in @ref QuaZipFileInfo64::extra. Another is located before the file itself, and is returned by this function. The file must be open first. @return the local extra field, or an empty array if there is none (or file is not open) */ QByteArray getLocalExtraField(); /// Returns the extended modification timestamp /** * The getExt*Time() functions only work if there is an extended timestamp * extra field (ID 0x5455) present. Otherwise, they all return invalid null * timestamps. * * Modification time, but not other times, can also be accessed through * @ref QuaZipFileInfo64 without the need to open the file first. * * @sa dateTime * @sa QuaZipFileInfo64::getExtModTime() * @sa getExtAcTime() * @sa getExtCrTime() * @return The extended modification time, UTC */ QDateTime getExtModTime(); /// Returns the extended access timestamp /** * The getExt*Time() functions only work if there is an extended timestamp * extra field (ID 0x5455) present. Otherwise, they all return invalid null * timestamps. * @sa dateTime * @sa QuaZipFileInfo64::getExtModTime() * @sa getExtModTime() * @sa getExtCrTime() * @return The extended access time, UTC */ QDateTime getExtAcTime(); /// Returns the extended creation timestamp /** * The getExt*Time() functions only work if there is an extended timestamp * extra field (ID 0x5455) present. Otherwise, they all return invalid null * timestamps. * @sa dateTime * @sa QuaZipFileInfo64::getExtModTime() * @sa getExtModTime() * @sa getExtAcTime() * @return The extended creation time, UTC */ QDateTime getExtCrTime(); }; #endif quazip-0.9.1/quazip/quazipfileinfo.cpp000066400000000000000000000140251366246114300201040ustar00rootroot00000000000000/* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include "quazipfileinfo.h" #include static QFile::Permissions permissionsFromExternalAttr(quint32 externalAttr) { quint32 uPerm = (externalAttr & 0xFFFF0000u) >> 16; QFile::Permissions perm = 0; if ((uPerm & 0400) != 0) perm |= QFile::ReadOwner; if ((uPerm & 0200) != 0) perm |= QFile::WriteOwner; if ((uPerm & 0100) != 0) perm |= QFile::ExeOwner; if ((uPerm & 0040) != 0) perm |= QFile::ReadGroup; if ((uPerm & 0020) != 0) perm |= QFile::WriteGroup; if ((uPerm & 0010) != 0) perm |= QFile::ExeGroup; if ((uPerm & 0004) != 0) perm |= QFile::ReadOther; if ((uPerm & 0002) != 0) perm |= QFile::WriteOther; if ((uPerm & 0001) != 0) perm |= QFile::ExeOther; return perm; } QFile::Permissions QuaZipFileInfo::getPermissions() const { return permissionsFromExternalAttr(externalAttr); } QFile::Permissions QuaZipFileInfo64::getPermissions() const { return permissionsFromExternalAttr(externalAttr); } bool QuaZipFileInfo64::toQuaZipFileInfo(QuaZipFileInfo &info) const { bool noOverflow = true; info.name = name; info.versionCreated = versionCreated; info.versionNeeded = versionNeeded; info.flags = flags; info.method = method; info.dateTime = dateTime; info.crc = crc; if (compressedSize > 0xFFFFFFFFu) { info.compressedSize = 0xFFFFFFFFu; noOverflow = false; } else { info.compressedSize = compressedSize; } if (uncompressedSize > 0xFFFFFFFFu) { info.uncompressedSize = 0xFFFFFFFFu; noOverflow = false; } else { info.uncompressedSize = uncompressedSize; } info.diskNumberStart = diskNumberStart; info.internalAttr = internalAttr; info.externalAttr = externalAttr; info.comment = comment; info.extra = extra; return noOverflow; } static QDateTime getNTFSTime(const QByteArray &extra, int position, int *fineTicks) { QDateTime dateTime; QuaExtraFieldHash extraHash = QuaZipFileInfo64::parseExtraField(extra); QList ntfsExtraFields = extraHash[QUAZIP_EXTRA_NTFS_MAGIC]; if (ntfsExtraFields.isEmpty()) return dateTime; QByteArray ntfsExtraField = ntfsExtraFields.at(0); if (ntfsExtraField.length() <= 4) return dateTime; QByteArray ntfsAttributes = ntfsExtraField.mid(4); QuaExtraFieldHash ntfsHash = QuaZipFileInfo64::parseExtraField(ntfsAttributes); QList ntfsTimeAttributes = ntfsHash[QUAZIP_EXTRA_NTFS_TIME_MAGIC]; if (ntfsTimeAttributes.isEmpty()) return dateTime; QByteArray ntfsTimes = ntfsTimeAttributes.at(0); if (ntfsTimes.size() < 24) return dateTime; QDataStream timeReader(ntfsTimes); timeReader.setByteOrder(QDataStream::LittleEndian); timeReader.device()->seek(position); quint64 time; timeReader >> time; QDateTime base(QDate(1601, 1, 1), QTime(0, 0), Qt::UTC); dateTime = base.addMSecs(time / 10000); if (fineTicks != NULL) { *fineTicks = static_cast(time % 10000); } return dateTime; } QDateTime QuaZipFileInfo64::getNTFSmTime(int *fineTicks) const { return getNTFSTime(extra, 0, fineTicks); } QDateTime QuaZipFileInfo64::getNTFSaTime(int *fineTicks) const { return getNTFSTime(extra, 8, fineTicks); } QDateTime QuaZipFileInfo64::getNTFScTime(int *fineTicks) const { return getNTFSTime(extra, 16, fineTicks); } QDateTime QuaZipFileInfo64::getExtTime(const QByteArray &extra, int flag) { QDateTime dateTime; QuaExtraFieldHash extraHash = QuaZipFileInfo64::parseExtraField(extra); QList extTimeFields = extraHash[QUAZIP_EXTRA_EXT_TIME_MAGIC]; if (extTimeFields.isEmpty()) return dateTime; QByteArray extTimeField = extTimeFields.at(0); if (extTimeField.length() < 1) return dateTime; QDataStream input(extTimeField); input.setByteOrder(QDataStream::LittleEndian); quint8 flags; input >> flags; int flagsRemaining = flags; while (!input.atEnd()) { int nextFlag = flagsRemaining & -flagsRemaining; flagsRemaining &= flagsRemaining - 1; qint32 time; input >> time; if (nextFlag == flag) { QDateTime base(QDate(1970, 1, 1), QTime(0, 0), Qt::UTC); dateTime = base.addSecs(time); return dateTime; } } return dateTime; } QDateTime QuaZipFileInfo64::getExtModTime() const { return getExtTime(extra, 1); } QuaExtraFieldHash QuaZipFileInfo64::parseExtraField(const QByteArray &extraField) { QDataStream input(extraField); input.setByteOrder(QDataStream::LittleEndian); QHash > result; while (!input.atEnd()) { quint16 id, size; input >> id; if (input.status() == QDataStream::ReadPastEnd) return result; input >> size; if (input.status() == QDataStream::ReadPastEnd) return result; QByteArray data; data.resize(size); int read = input.readRawData(data.data(), data.size()); if (read < data.size()) return result; result[id] << data; } return result; } quazip-0.9.1/quazip/quazipfileinfo.h000066400000000000000000000177401366246114300175600ustar00rootroot00000000000000#ifndef QUA_ZIPFILEINFO_H #define QUA_ZIPFILEINFO_H /* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include #include #include #include #include "quazip_global.h" /// The typedef to store extra field parse results typedef QHash > QuaExtraFieldHash; /// Information about a file inside archive. /** * \deprecated Use QuaZipFileInfo64 instead. Not only it supports large files, * but also more convenience methods as well. * * Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to * fill this structure. */ struct QUAZIP_EXPORT QuaZipFileInfo { /// File name. QString name; /// Version created by. quint16 versionCreated; /// Version needed to extract. quint16 versionNeeded; /// General purpose flags. quint16 flags; /// Compression method. quint16 method; /// Last modification date and time. QDateTime dateTime; /// CRC. quint32 crc; /// Compressed file size. quint32 compressedSize; /// Uncompressed file size. quint32 uncompressedSize; /// Disk number start. quint16 diskNumberStart; /// Internal file attributes. quint16 internalAttr; /// External file attributes. quint32 externalAttr; /// Comment. QString comment; /// Extra field. QByteArray extra; /// Get the file permissions. /** Returns the high 16 bits of external attributes converted to QFile::Permissions. */ QFile::Permissions getPermissions() const; }; /// Information about a file inside archive (with zip64 support). /** Call QuaZip::getCurrentFileInfo() or QuaZipFile::getFileInfo() to * fill this structure. */ struct QUAZIP_EXPORT QuaZipFileInfo64 { /// File name. QString name; /// Version created by. quint16 versionCreated; /// Version needed to extract. quint16 versionNeeded; /// General purpose flags. quint16 flags; /// Compression method. quint16 method; /// Last modification date and time. /** * This is the time stored in the standard ZIP header. This format only allows * to store time with 2-second precision, so the seconds will always be even * and the milliseconds will always be zero. If you need more precise * date and time, you can try to call the getNTFSmTime() function or * its siblings, provided that the archive itself contains these NTFS times. */ QDateTime dateTime; /// CRC. quint32 crc; /// Compressed file size. quint64 compressedSize; /// Uncompressed file size. quint64 uncompressedSize; /// Disk number start. quint16 diskNumberStart; /// Internal file attributes. quint16 internalAttr; /// External file attributes. quint32 externalAttr; /// Comment. QString comment; /// Extra field. QByteArray extra; /// Get the file permissions. /** Returns the high 16 bits of external attributes converted to QFile::Permissions. */ QFile::Permissions getPermissions() const; /// Converts to QuaZipFileInfo /** If any of the fields are greater than 0xFFFFFFFFu, they are set to 0xFFFFFFFFu exactly, not just truncated. This function should be mainly used for compatibility with the old code expecting QuaZipFileInfo, in the cases when it's impossible or otherwise unadvisable (due to ABI compatibility reasons, for example) to modify that old code to use QuaZipFileInfo64. \return \c true if all fields converted correctly, \c false if an overflow occured. */ bool toQuaZipFileInfo(QuaZipFileInfo &info) const; /// Returns the NTFS modification time /** * The getNTFS*Time() functions only work if there is an NTFS extra field * present. Otherwise, they all return invalid null timestamps. * @param fineTicks If not NULL, the fractional part of milliseconds returned * there, measured in 100-nanosecond ticks. Will be set to * zero if there is no NTFS extra field. * @sa dateTime * @sa getNTFSaTime() * @sa getNTFScTime() * @return The NTFS modification time, UTC */ QDateTime getNTFSmTime(int *fineTicks = NULL) const; /// Returns the NTFS access time /** * The getNTFS*Time() functions only work if there is an NTFS extra field * present. Otherwise, they all return invalid null timestamps. * @param fineTicks If not NULL, the fractional part of milliseconds returned * there, measured in 100-nanosecond ticks. Will be set to * zero if there is no NTFS extra field. * @sa dateTime * @sa getNTFSmTime() * @sa getNTFScTime() * @return The NTFS access time, UTC */ QDateTime getNTFSaTime(int *fineTicks = NULL) const; /// Returns the NTFS creation time /** * The getNTFS*Time() functions only work if there is an NTFS extra field * present. Otherwise, they all return invalid null timestamps. * @param fineTicks If not NULL, the fractional part of milliseconds returned * there, measured in 100-nanosecond ticks. Will be set to * zero if there is no NTFS extra field. * @sa dateTime * @sa getNTFSmTime() * @sa getNTFSaTime() * @return The NTFS creation time, UTC */ QDateTime getNTFScTime(int *fineTicks = NULL) const; /// Returns the extended modification timestamp /** * The getExt*Time() functions only work if there is an extended timestamp * extra field (ID 0x5455) present. Otherwise, they all return invalid null * timestamps. * * QuaZipFileInfo64 only contains the modification time because it's extracted * from @ref extra, which contains the global extra field, and access and * creation time are in the local header which can be accessed through * @ref QuaZipFile. * * @sa dateTime * @sa QuaZipFile::getExtModTime() * @sa QuaZipFile::getExtAcTime() * @sa QuaZipFile::getExtCrTime() * @return The extended modification time, UTC */ QDateTime getExtModTime() const; /// Checks whether the file is encrypted. bool isEncrypted() const {return (flags & 1) != 0;} /// Parses extra field /** * The returned hash table contains a list of data blocks for every header ID * in the provided extra field. The number of data blocks in a hash table value * equals to the number of occurrences of the appropriate header id. In most cases, * a block with a specific header ID only occurs once, and therefore the returned * hash table will contain a list consisting of a single element for that header ID. * * @param extraField extra field to parse * @return header id to list of data block hash */ static QuaExtraFieldHash parseExtraField(const QByteArray &extraField); /// Extracts extended time from the extra field /** * Utility function used by various getExt*Time() functions, but can be used directly * if the extra field is obtained elsewhere (from a third party library, for example). * * @param extra the extra field for a file * @param flag 1 - modification time, 2 - access time, 4 - creation time * @return the extracted time or null QDateTime if not present * @sa getExtModTime() * @sa QuaZipFile::getExtModTime() * @sa QuaZipFile::getExtAcTime() * @sa QuaZipFile::getExtCrTime() */ static QDateTime getExtTime(const QByteArray &extra, int flag); }; #endif quazip-0.9.1/quazip/quazipnewinfo.cpp000066400000000000000000000251061366246114300177600ustar00rootroot00000000000000/* Copyright (C) 2005-2014 Sergey A. Tachenov This file is part of QuaZIP. QuaZIP is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version. QuaZIP is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with QuaZIP. If not, see . See COPYING file for the full LGPL text. Original ZIP package is copyrighted by Gilles Vollant and contributors, see quazip/(un)zip.h files for details. Basically it's the zlib license. */ #include #include "quazipnewinfo.h" #include static void QuaZipNewInfo_setPermissions(QuaZipNewInfo *info, QFile::Permissions perm, bool isDir, bool isSymLink = false) { quint32 uPerm = isDir ? 0040000 : 0100000; if ( isSymLink ) { #ifdef Q_OS_WIN uPerm = 0200000; #else uPerm = 0120000; #endif } if ((perm & QFile::ReadOwner) != 0) uPerm |= 0400; if ((perm & QFile::WriteOwner) != 0) uPerm |= 0200; if ((perm & QFile::ExeOwner) != 0) uPerm |= 0100; if ((perm & QFile::ReadGroup) != 0) uPerm |= 0040; if ((perm & QFile::WriteGroup) != 0) uPerm |= 0020; if ((perm & QFile::ExeGroup) != 0) uPerm |= 0010; if ((perm & QFile::ReadOther) != 0) uPerm |= 0004; if ((perm & QFile::WriteOther) != 0) uPerm |= 0002; if ((perm & QFile::ExeOther) != 0) uPerm |= 0001; info->externalAttr = (info->externalAttr & ~0xFFFF0000u) | (uPerm << 16); } template void QuaZipNewInfo_init(QuaZipNewInfo &self, const FileInfo &existing) { self.name = existing.name; self.dateTime = existing.dateTime; self.internalAttr = existing.internalAttr; self.externalAttr = existing.externalAttr; self.comment = existing.comment; self.extraLocal = existing.extra; self.extraGlobal = existing.extra; self.uncompressedSize = existing.uncompressedSize; } QuaZipNewInfo::QuaZipNewInfo(const QuaZipFileInfo &existing) { QuaZipNewInfo_init(*this, existing); } QuaZipNewInfo::QuaZipNewInfo(const QuaZipFileInfo64 &existing) { QuaZipNewInfo_init(*this, existing); } QuaZipNewInfo::QuaZipNewInfo(const QString& name): name(name), dateTime(QDateTime::currentDateTime()), internalAttr(0), externalAttr(0), uncompressedSize(0) { } QuaZipNewInfo::QuaZipNewInfo(const QString& name, const QString& file): name(name), internalAttr(0), externalAttr(0), uncompressedSize(0) { QFileInfo info(file); QDateTime lm = info.lastModified(); if (!info.exists()) { dateTime = QDateTime::currentDateTime(); } else { dateTime = lm; QuaZipNewInfo_setPermissions(this, info.permissions(), info.isDir(), info.isSymLink()); } } void QuaZipNewInfo::setFileDateTime(const QString& file) { QFileInfo info(file); QDateTime lm = info.lastModified(); if (info.exists()) dateTime = lm; } void QuaZipNewInfo::setFilePermissions(const QString &file) { QFileInfo info = QFileInfo(file); QFile::Permissions perm = info.permissions(); QuaZipNewInfo_setPermissions(this, perm, info.isDir(), info.isSymLink()); } void QuaZipNewInfo::setPermissions(QFile::Permissions permissions) { QuaZipNewInfo_setPermissions(this, permissions, name.endsWith(QLatin1String("/"))); } void QuaZipNewInfo::setFileNTFSTimes(const QString &fileName) { QFileInfo fi(fileName); if (!fi.exists()) { qWarning("QuaZipNewInfo::setFileNTFSTimes(): '%s' doesn't exist", fileName.toUtf8().constData()); return; } setFileNTFSmTime(fi.lastModified()); setFileNTFSaTime(fi.lastRead()); #if (QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)) setFileNTFScTime(fi.birthTime()); #else setFileNTFScTime(fi.created()); #endif } static void setNTFSTime(QByteArray &extra, const QDateTime &time, int position, int fineTicks) { int ntfsPos = -1, timesPos = -1; unsigned ntfsLength = 0, ntfsTimesLength = 0; for (int i = 0; i <= extra.size() - 4; ) { unsigned type = static_cast(static_cast( extra.at(i))) | (static_cast(static_cast( extra.at(i + 1))) << 8); i += 2; unsigned length = static_cast(static_cast( extra.at(i))) | (static_cast(static_cast( extra.at(i + 1))) << 8); i += 2; if (type == QUAZIP_EXTRA_NTFS_MAGIC) { ntfsPos = i - 4; // the beginning of the NTFS record ntfsLength = length; if (length <= 4) { break; // no times in the NTFS record } i += 4; // reserved while (i <= extra.size() - 4) { unsigned tag = static_cast( static_cast(extra.at(i))) | (static_cast( static_cast(extra.at(i + 1))) << 8); i += 2; unsigned tagsize = static_cast( static_cast(extra.at(i))) | (static_cast( static_cast(extra.at(i + 1))) << 8); i += 2; if (tag == QUAZIP_EXTRA_NTFS_TIME_MAGIC) { timesPos = i - 4; // the beginning of the NTFS times tag ntfsTimesLength = tagsize; break; } else { i += tagsize; } } break; // I ain't going to search for yet another NTFS record! } else { i += length; } } if (ntfsPos == -1) { // No NTFS record, need to create one. ntfsPos = extra.size(); ntfsLength = 32; extra.resize(extra.size() + 4 + ntfsLength); // the NTFS record header extra[ntfsPos] = static_cast(QUAZIP_EXTRA_NTFS_MAGIC); extra[ntfsPos + 1] = static_cast(QUAZIP_EXTRA_NTFS_MAGIC >> 8); extra[ntfsPos + 2] = 32; // the 2-byte size in LittleEndian extra[ntfsPos + 3] = 0; // zero the record memset(extra.data() + ntfsPos + 4, 0, 32); timesPos = ntfsPos + 8; // now set the tag data extra[timesPos] = static_cast(QUAZIP_EXTRA_NTFS_TIME_MAGIC); extra[timesPos + 1] = static_cast(QUAZIP_EXTRA_NTFS_TIME_MAGIC >> 8); // the size: extra[timesPos + 2] = 24; extra[timesPos + 3] = 0; ntfsTimesLength = 24; } if (timesPos == -1) { // No time tag in the NTFS record, need to add one. timesPos = ntfsPos + 4 + ntfsLength; extra.resize(extra.size() + 28); // Now we need to move the rest of the field // (possibly zero bytes, but memmove() is OK with that). // 0 ......... ntfsPos .. ntfsPos + 4 ... timesPos //
memmove(extra.data() + timesPos + 28, extra.data() + timesPos, extra.size() - 28 - timesPos); ntfsLength += 28; // now set the tag data extra[timesPos] = static_cast(QUAZIP_EXTRA_NTFS_TIME_MAGIC); extra[timesPos + 1] = static_cast(QUAZIP_EXTRA_NTFS_TIME_MAGIC >> 8); // the size: extra[timesPos + 2] = 24; extra[timesPos + 3] = 0; // zero the record memset(extra.data() + timesPos + 4, 0, 24); ntfsTimesLength = 24; } if (ntfsTimesLength < 24) { // Broken times field. OK, this is really unlikely, but just in case... size_t timesEnd = timesPos + 4 + ntfsTimesLength; extra.resize(extra.size() + (24 - ntfsTimesLength)); // Move it! // 0 ......... timesPos .... timesPos + 4 .. timesEnd //