File indexing completed on 2024-04-21 03:52:31

0001 /* This file is part of the KDE libraries
0002    SPDX-FileCopyrightText: 2000-2005 David Faure <faure@kde.org>
0003    SPDX-FileCopyrightText: 2003 Leo Savernik <l.savernik@aon.at>
0004 
0005    Moved from ktar.h by Roberto Teixeira <maragato@kde.org>
0006 
0007    SPDX-License-Identifier: LGPL-2.0-or-later
0008 */
0009 #ifndef KARCHIVEENTRY_H
0010 #define KARCHIVEENTRY_H
0011 
0012 #include <sys/stat.h>
0013 #include <sys/types.h>
0014 
0015 #include <karchive_export.h>
0016 
0017 #ifdef Q_OS_WIN
0018 #include <qplatformdefs.h> // mode_t
0019 #endif
0020 
0021 class KArchiveDirectory;
0022 class KArchiveFile;
0023 class KArchive;
0024 
0025 class KArchiveEntryPrivate;
0026 /**
0027  * @class KArchiveEntry karchiveentry.h KArchiveEntry
0028  *
0029  * A base class for entries in an KArchive.
0030  * @short Base class for the archive-file's directory structure.
0031  *
0032  * @see KArchiveFile
0033  * @see KArchiveDirectory
0034  */
0035 class KARCHIVE_EXPORT KArchiveEntry
0036 {
0037 public:
0038     /**
0039      * Creates a new entry.
0040      * @param archive the entries archive
0041      * @param name the name of the entry
0042      * @param access the permissions in unix format
0043      * @param date the date (in seconds since 1970)
0044      * @param user the user that owns the entry
0045      * @param group the group that owns the entry
0046      * @param symlink the symlink, or QString()
0047      */
0048     KArchiveEntry(KArchive *archive, const QString &name, int access, const QDateTime &date, const QString &user, const QString &group, const QString &symlink);
0049 
0050     virtual ~KArchiveEntry();
0051 
0052     /**
0053      * Creation date of the file.
0054      * @return the creation date
0055      */
0056     QDateTime date() const;
0057 
0058     /**
0059      * Name of the file without path.
0060      * @return the file name without path
0061      */
0062     QString name() const;
0063     /**
0064      * The permissions and mode flags as returned by the stat() function
0065      * in st_mode.
0066      * @return the permissions
0067      */
0068     mode_t permissions() const;
0069     /**
0070      * User who created the file.
0071      * @return the owner of the file
0072      */
0073     QString user() const;
0074     /**
0075      * Group of the user who created the file.
0076      * @return the group of the file
0077      */
0078     QString group() const;
0079 
0080     /**
0081      * Symlink if there is one.
0082      * @return the symlink, or QString()
0083      */
0084     QString symLinkTarget() const;
0085 
0086     /**
0087      * Checks whether the entry is a file.
0088      * @return true if this entry is a file
0089      */
0090     virtual bool isFile() const;
0091 
0092     /**
0093      * Checks whether the entry is a directory.
0094      * @return true if this entry is a directory
0095      */
0096     virtual bool isDirectory() const;
0097 
0098 protected:
0099     KArchive *archive() const;
0100 
0101 protected:
0102     virtual void virtual_hook(int id, void *data);
0103 
0104 private:
0105     KArchiveEntryPrivate *const d;
0106 };
0107 
0108 #endif