File indexing completed on 2024-09-08 05:08:08
0001 // clang-format off 0002 /** 0003 * KDiff3 - Text Diff And Merge Tool 0004 * 0005 * SPDX-FileCopyrightText: 2021 Michael Reeves <reeves.87@gmail.com> 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 * 0008 */ 0009 // clang-format on 0010 0011 #ifndef FILEACCESSJOBHANDLER_H 0012 #define FILEACCESSJOBHANDLER_H 0013 0014 #include "fileaccess.h" 0015 0016 #include <QObject> 0017 #include <QString> 0018 0019 #if HAS_KFKIO && !defined AUTOTEST 0020 #include <KIO/UDSEntry> 0021 #endif 0022 0023 namespace KIO { 0024 class Job; 0025 } 0026 0027 class KJob; 0028 0029 class FileAccessJobHandler: public QObject 0030 { 0031 public: 0032 FileAccessJobHandler(FileAccess* pFileAccess) 0033 { 0034 mFileAccess = pFileAccess; 0035 } 0036 0037 virtual FileAccessJobHandler* copy(FileAccess* fileAccess) = 0; 0038 //This exists soley to allow FileAccess to be no-except movable 0039 void setFileAccess(FileAccess* pFileAccess) noexcept { mFileAccess = pFileAccess; } 0040 virtual bool get(void* pDestBuffer, long maxLength) = 0; 0041 virtual bool put(const void* pSrcBuffer, long maxLength, bool bOverwrite, bool bResume = false, qint32 permissions = -1) = 0; 0042 virtual bool stat(bool bWantToWrite = false) = 0; 0043 virtual bool copyFile(const QString& dest) = 0; 0044 virtual bool rename(const FileAccess& dest) = 0; 0045 virtual bool listDir(DirectoryList* pDirList, bool bRecursive, bool bFindHidden, 0046 const QString& filePattern, const QString& fileAntiPattern, 0047 const QString& dirAntiPattern, bool bFollowDirLinks, IgnoreList& ignoreList) = 0; 0048 virtual bool removeFile(const QUrl& fileName) = 0; 0049 virtual bool symLink(const QUrl& linkTarget, const QUrl& linkLocation) = 0; 0050 0051 protected: 0052 FileAccess* mFileAccess = nullptr; 0053 bool m_bSuccess = false; 0054 0055 // Data needed during Job 0056 qint64 m_transferredBytes = 0; 0057 char* m_pTransferBuffer = nullptr; // Needed during get or put 0058 qint64 m_maxLength = 0; 0059 0060 QString m_filePattern; 0061 QString m_fileAntiPattern; 0062 QString m_dirAntiPattern; 0063 DirectoryList* m_pDirList = nullptr; 0064 bool m_bFindHidden = false; 0065 bool m_bRecursive = false; 0066 bool m_bFollowDirLinks = false; 0067 0068 private: 0069 virtual bool mkDirImp(const QString& dirName) = 0; 0070 virtual bool rmDirImp(const QString& dirName) = 0; 0071 }; 0072 0073 #endif /* FILEACCESSJOBHANDLER_H */