| 1 | #ifndef QUA_ZIPNEWINFO_H
|
|---|
| 2 | #define QUA_ZIPNEWINFO_H
|
|---|
| 3 |
|
|---|
| 4 | /*
|
|---|
| 5 | -- A kind of "standard" GPL license statement --
|
|---|
| 6 | QuaZIP - a Qt/C++ wrapper for the ZIP/UNZIP package
|
|---|
| 7 | Copyright (C) 2005-2007 Sergey A. Tachenov
|
|---|
| 8 |
|
|---|
| 9 | This program is free software; you can redistribute it and/or modify it
|
|---|
| 10 | under the terms of the GNU General Public License as published by the
|
|---|
| 11 | Free Software Foundation; either version 2 of the License, or (at your
|
|---|
| 12 | option) any later version.
|
|---|
| 13 |
|
|---|
| 14 | This program is distributed in the hope that it will be useful, but
|
|---|
| 15 | WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
|
|---|
| 17 | Public License for more details.
|
|---|
| 18 |
|
|---|
| 19 | You should have received a copy of the GNU General Public License along
|
|---|
| 20 | with this program; if not, write to the Free Software Foundation, Inc.,
|
|---|
| 21 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 22 |
|
|---|
| 23 | -- A kind of "standard" GPL license statement ends here --
|
|---|
| 24 |
|
|---|
| 25 | See COPYING file for GPL.
|
|---|
| 26 |
|
|---|
| 27 | You are also permitted to use QuaZIP under the terms of LGPL (see
|
|---|
| 28 | COPYING.LGPL). You are free to choose either license, but please note
|
|---|
| 29 | that QuaZIP makes use of Qt, which is not licensed under LGPL. So if
|
|---|
| 30 | you are using Open Source edition of Qt, you therefore MUST use GPL for
|
|---|
| 31 | your code based on QuaZIP, since it would be also based on Qt in this
|
|---|
| 32 | case. If you are Qt commercial license owner, then you are free to use
|
|---|
| 33 | QuaZIP as long as you respect either GPL or LGPL for QuaZIP code.
|
|---|
| 34 | **/
|
|---|
| 35 |
|
|---|
| 36 | #include <QDateTime>
|
|---|
| 37 | #include <QString>
|
|---|
| 38 |
|
|---|
| 39 | /// Information about a file to be created.
|
|---|
| 40 | /** This structure holds information about a file to be created inside
|
|---|
| 41 | * ZIP archive. At least name should be set to something correct before
|
|---|
| 42 | * passing this structure to
|
|---|
| 43 | * QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool).
|
|---|
| 44 | **/
|
|---|
| 45 | struct QuaZipNewInfo {
|
|---|
| 46 | /// File name.
|
|---|
| 47 | /** This field holds file name inside archive, including path relative
|
|---|
| 48 | * to archive root.
|
|---|
| 49 | **/
|
|---|
| 50 | QString name;
|
|---|
| 51 | /// File timestamp.
|
|---|
| 52 | /** This is the last file modification date and time. Will be stored
|
|---|
| 53 | * in the archive central directory. It is a good practice to set it
|
|---|
| 54 | * to the source file timestamp instead of archive creating time. Use
|
|---|
| 55 | * setFileDateTime() or QuaZipNewInfo(const QString&, const QString&).
|
|---|
| 56 | **/
|
|---|
| 57 | QDateTime dateTime;
|
|---|
| 58 | /// File internal attributes.
|
|---|
| 59 | quint16 internalAttr;
|
|---|
| 60 | /// File external attributes.
|
|---|
| 61 | quint32 externalAttr;
|
|---|
| 62 | /// File comment.
|
|---|
| 63 | /** Will be encoded using QuaZip::getCommentCodec().
|
|---|
| 64 | **/
|
|---|
| 65 | QString comment;
|
|---|
| 66 | /// File local extra field.
|
|---|
| 67 | QByteArray extraLocal;
|
|---|
| 68 | /// File global extra field.
|
|---|
| 69 | QByteArray extraGlobal;
|
|---|
| 70 | /// Uncompressed file size.
|
|---|
| 71 | /** This is only needed if you are using raw file zipping mode, i. e.
|
|---|
| 72 | * adding precompressed file in the zip archive.
|
|---|
| 73 | **/
|
|---|
| 74 | ulong uncompressedSize;
|
|---|
| 75 | /// Constructs QuaZipNewInfo instance.
|
|---|
| 76 | /** Initializes name with \a name, dateTime with current date and
|
|---|
| 77 | * time. Attributes are initialized with zeros, comment and extra
|
|---|
| 78 | * field with null values.
|
|---|
| 79 | **/
|
|---|
| 80 | QuaZipNewInfo(const QString& name);
|
|---|
| 81 | /// Constructs QuaZipNewInfo instance.
|
|---|
| 82 | /** Initializes name with \a name and dateTime with timestamp of the
|
|---|
| 83 | * file named \a file. If the \a file does not exists or its timestamp
|
|---|
| 84 | * is inaccessible (e. g. you do not have read permission for the
|
|---|
| 85 | * directory file in), uses current date and time. Attributes are
|
|---|
| 86 | * initialized with zeros, comment and extra field with null values.
|
|---|
| 87 | *
|
|---|
| 88 | * \sa setFileDateTime()
|
|---|
| 89 | **/
|
|---|
| 90 | QuaZipNewInfo(const QString& name, const QString& file);
|
|---|
| 91 | /// Sets the file timestamp from the existing file.
|
|---|
| 92 | /** Use this function to set the file timestamp from the existing
|
|---|
| 93 | * file. Use it like this:
|
|---|
| 94 | * \code
|
|---|
| 95 | * QuaZipFile zipFile(&zip);
|
|---|
| 96 | * QFile file("file-to-add");
|
|---|
| 97 | * file.open(QIODevice::ReadOnly);
|
|---|
| 98 | * QuaZipNewInfo info("file-name-in-archive");
|
|---|
| 99 | * info.setFileDateTime("file-to-add"); // take the timestamp from file
|
|---|
| 100 | * zipFile.open(QIODevice::WriteOnly, info);
|
|---|
| 101 | * \endcode
|
|---|
| 102 | *
|
|---|
| 103 | * This function does not change dateTime if some error occured (e. g.
|
|---|
| 104 | * file is inaccessible).
|
|---|
| 105 | **/
|
|---|
| 106 | void setFileDateTime(const QString& file);
|
|---|
| 107 | };
|
|---|
| 108 |
|
|---|
| 109 | #endif
|
|---|