#ifndef MODARCHIVE_H #define MODARCHIVE_H #include #include #include #include #include class ArchiveCacheEntry : public QObject { Q_OBJECT public: QByteArray m_data; int m_accessCount; bool m_cached; bool m_loading; off_t m_offset; struct stat m_stat; time_t m_lastAccess; QMutex m_mutex; bool m_locked; ArchiveCacheEntry(QObject *parent=NULL) : QObject(parent), m_accessCount{0}, m_cached{false}, m_loading{false}, m_offset{0}, m_lastAccess{0}, m_locked{false} { } }; class Archive : public QObject { Q_OBJECT ar_stream *m_stream; ar_archive *m_archive; QString m_arcpath; QMutex m_mutex; bool m_suicidal; QMap< QString, ArchiveCacheEntry * > m_cache; private: bool open(); bool close(); public: explicit Archive(const QString &arcpath, QObject *parent = nullptr); ~Archive(); QString getPath() { return m_arcpath; } QMap *getEntries(); QByteArray *getEntry(const QString &path); void releaseEntry(const QString &path); bool contains(const QString &path); ArchiveCacheEntry *cache(const QString &path); void cleanCache(time_t olderThan); void killme(); void checkIfLifeIsWorthIt(); signals: }; #endif // MODARCHIVE_H