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