xlsxzipreader.cpp 848 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // xlsxzipreader.cpp
  2. #include "xlsxzipreader_p.h"
  3. #include <private/qzipreader_p.h>
  4. QT_BEGIN_NAMESPACE_XLSX
  5. ZipReader::ZipReader(const QString &filePath) :
  6. m_reader(new QZipReader(filePath))
  7. {
  8. init();
  9. }
  10. ZipReader::ZipReader(QIODevice *device) :
  11. m_reader(new QZipReader(device))
  12. {
  13. init();
  14. }
  15. ZipReader::~ZipReader()
  16. {
  17. }
  18. void ZipReader::init()
  19. {
  20. const auto& allFiles = m_reader->fileInfoList();
  21. for (const auto &fi : allFiles) {
  22. if (fi.isFile || (!fi.isDir && !fi.isFile && !fi.isSymLink))
  23. m_filePaths.append(fi.filePath);
  24. }
  25. }
  26. bool ZipReader::exists() const
  27. {
  28. return m_reader->exists();
  29. }
  30. QStringList ZipReader::filePaths() const
  31. {
  32. return m_filePaths;
  33. }
  34. QByteArray ZipReader::fileData(const QString &fileName) const
  35. {
  36. return m_reader->fileData(fileName);
  37. }
  38. QT_END_NAMESPACE_XLSX