Guest User

Untitled

a guest
Sep 16th, 2014
218
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #pragma once
  2.  
  3. //#include <QtCore/private/qabstractfileengine_p.h>
  4. #include <QtCore/5.3.1/QtCore/private/qabstractfileengine_p.h>
  5.  
  6. #include <Utilities/PackageReader.h>
  7.  
  8. namespace qml
  9. {
  10.     class ResourcesEngineHandler : public QAbstractFileEngineHandler
  11.     {
  12.     public:
  13.         ResourcesEngineHandler();
  14.  
  15.         QAbstractFileEngine*    create(const QString& fileName) const;
  16.  
  17.     private:
  18.         QString mCurrentDir;
  19.     };
  20.  
  21.     class ResourcesEngine : public QAbstractFileEngine
  22.     {
  23.     public:
  24.         ResourcesEngine(const QString& fileName);
  25.  
  26.         bool open(QIODevice::OpenMode openMode) override;
  27.         bool close() override;
  28.         bool flush() override;
  29.         bool syncToDisk() override;
  30.         qint64 size() const override;
  31.         qint64 pos() const override;
  32.         bool seek(qint64 pos) override;
  33.         bool isSequential() const override;
  34.         bool remove() override;
  35.         bool copy(const QString& newName) override;
  36.         bool rename(const QString& newName) override;
  37.         bool renameOverwrite(const QString& newName) override;
  38.         bool link(const QString& newName) override;
  39.         bool mkdir(const QString& dirName, bool createParentDirectories) const override;
  40.         bool rmdir(const QString& dirName, bool recurseParentDirectories) const override;
  41.         bool setSize(qint64 size) override;
  42.         bool caseSensitive() const override;
  43.         bool isRelativePath() const override;
  44.         QStringList entryList(QDir::Filters filters, const QStringList& filterNames) const override;
  45.         FileFlags fileFlags(FileFlags type = FileInfoAll) const override;
  46.         bool setPermissions(uint perms) override;
  47.         QString fileName(FileName file = DefaultName) const override;
  48.         uint ownerId(FileOwner) const override;
  49.         QString owner(FileOwner) const override;
  50.         QDateTime fileTime(FileTime time) const override;
  51.         void setFileName(const QString& file) override;
  52.         int handle() const override;
  53.  
  54.         Iterator *beginEntryList(QDir::Filters filters, const QStringList& filterNames) override;
  55.         Iterator *endEntryList() override;
  56.  
  57.         qint64 read(char *data, qint64 maxlen) override;
  58.         qint64 readLine(char *data, qint64 maxlen) override;
  59.         qint64 write(const char *data, qint64 len) override;
  60.         bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) override;
  61.         bool supportsExtension(Extension extension) const override;
  62.  
  63.     private:
  64.         QString             mPath;
  65.         packageReader::File mFile;
  66.     };
  67.  
  68.     class ResourcesEngineIterator : public QAbstractFileEngineIterator
  69.     {
  70.     public:
  71.         ResourcesEngineIterator(QDir::Filters filters, const QStringList& nameFilters, const std::vector<packageReader::FileInfo>& infos, bool haveFolders, bool isEndIterator);
  72.  
  73.         QString next() override;
  74.         bool    hasNext() const override;
  75.         QString currentFileName() const override;
  76.  
  77.     private:
  78.         bool                                    mHaveFolders;
  79.         bool                                    mIsEndIterator;
  80.         int                                     mIndex;
  81.         std::vector<packageReader::FileInfo>    mFiles;
  82.     };
  83. }
RAW Paste Data