misc/quazip/quazipnewinfo.h
author sheepluva
Sat, 22 Oct 2011 18:24:36 +0200
changeset 6185 a6aa2d44f390
parent 5752 ea95ee97c805
child 7889 57b117d441b9
permissions -rw-r--r--
document css files better
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5752
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     1
#ifndef QUA_ZIPNEWINFO_H
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     2
#define QUA_ZIPNEWINFO_H
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     3
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     4
/*
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     5
Copyright (C) 2005-2011 Sergey A. Tachenov
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     6
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     7
This program is free software; you can redistribute it and/or modify it
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     8
under the terms of the GNU Lesser General Public License as published by
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
     9
the Free Software Foundation; either version 2 of the License, or (at
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    10
your option) any later version.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    11
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    12
This program is distributed in the hope that it will be useful, but
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    13
WITHOUT ANY WARRANTY; without even the implied warranty of
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    15
General Public License for more details.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    16
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    17
You should have received a copy of the GNU Lesser General Public License
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    18
along with this program; if not, write to the Free Software Foundation,
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    19
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    20
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    21
See COPYING file for the full LGPL text.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    22
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    23
Original ZIP package is copyrighted by Gilles Vollant, see
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    24
quazip/(un)zip.h files for details, basically it's zlib license.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    25
 **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    26
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    27
#include <QDateTime>
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    28
#include <QString>
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    29
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    30
#include "quazip_global.h"
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    31
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    32
/// Information about a file to be created.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    33
/** This structure holds information about a file to be created inside
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    34
 * ZIP archive. At least name should be set to something correct before
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    35
 * passing this structure to
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    36
 * QuaZipFile::open(OpenMode,const QuaZipNewInfo&,int,int,bool).
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    37
 **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    38
struct QUAZIP_EXPORT QuaZipNewInfo {
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    39
  /// File name.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    40
  /** This field holds file name inside archive, including path relative
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    41
   * to archive root.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    42
   **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    43
  QString name;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    44
  /// File timestamp.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    45
  /** This is the last file modification date and time. Will be stored
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    46
   * in the archive central directory. It is a good practice to set it
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    47
   * to the source file timestamp instead of archive creating time. Use
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    48
   * setFileDateTime() or QuaZipNewInfo(const QString&, const QString&).
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    49
   **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    50
  QDateTime dateTime;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    51
  /// File internal attributes.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    52
  quint16 internalAttr;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    53
  /// File external attributes.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    54
  quint32 externalAttr;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    55
  /// File comment.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    56
  /** Will be encoded using QuaZip::getCommentCodec().
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    57
   **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    58
  QString comment;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    59
  /// File local extra field.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    60
  QByteArray extraLocal;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    61
  /// File global extra field.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    62
  QByteArray extraGlobal;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    63
  /// Uncompressed file size.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    64
  /** This is only needed if you are using raw file zipping mode, i. e.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    65
   * adding precompressed file in the zip archive.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    66
   **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    67
  ulong uncompressedSize;
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    68
  /// Constructs QuaZipNewInfo instance.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    69
  /** Initializes name with \a name, dateTime with current date and
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    70
   * time. Attributes are initialized with zeros, comment and extra
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    71
   * field with null values.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    72
   **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    73
  QuaZipNewInfo(const QString& name);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    74
  /// Constructs QuaZipNewInfo instance.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    75
  /** Initializes name with \a name and dateTime with timestamp of the
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    76
   * file named \a file. If the \a file does not exists or its timestamp
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    77
   * is inaccessible (e. g. you do not have read permission for the
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    78
   * directory file in), uses current date and time. Attributes are
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    79
   * initialized with zeros, comment and extra field with null values.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    80
   * 
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    81
   * \sa setFileDateTime()
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    82
   **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    83
  QuaZipNewInfo(const QString& name, const QString& file);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    84
  /// Sets the file timestamp from the existing file.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    85
  /** Use this function to set the file timestamp from the existing
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    86
   * file. Use it like this:
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    87
   * \code
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    88
   * QuaZipFile zipFile(&zip);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    89
   * QFile file("file-to-add");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    90
   * file.open(QIODevice::ReadOnly);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    91
   * QuaZipNewInfo info("file-name-in-archive");
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    92
   * info.setFileDateTime("file-to-add"); // take the timestamp from file
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    93
   * zipFile.open(QIODevice::WriteOnly, info);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    94
   * \endcode
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    95
   *
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    96
   * This function does not change dateTime if some error occured (e. g.
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    97
   * file is inaccessible).
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    98
   **/
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
    99
  void setFileDateTime(const QString& file);
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   100
};
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   101
ea95ee97c805 Add QuaZIP library to build system
unc0rr
parents:
diff changeset
   102
#endif