FailDevice.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (C) 2015 Felix Geyer <debfx@fobos.de>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 or (at your option)
  7. * version 3 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef KEEPASSX_FAILDEVICE_H
  18. #define KEEPASSX_FAILDEVICE_H
  19. #include <QBuffer>
  20. class FailDevice : public QBuffer
  21. {
  22. Q_OBJECT
  23. public:
  24. explicit FailDevice(int failAfter, QObject* parent = nullptr);
  25. bool open(QIODevice::OpenMode openMode) override;
  26. protected:
  27. qint64 readData(char* data, qint64 len) override;
  28. qint64 writeData(const char* data, qint64 len) override;
  29. private:
  30. int m_failAfter;
  31. int m_readCount;
  32. int m_writeCount;
  33. };
  34. #endif // KEEPASSX_FAILDEVICE_H