File indexing completed on 2024-12-08 13:30:47
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 DEFAULTFILEACCESSJOBHANDLER_H 0012 #define DEFAULTFILEACCESSJOBHANDLER_H 0013 0014 #include "FileAccessJobHandler.h" 0015 0016 #include "DirectoryList.h" // for DirectoryList 0017 0018 #include <QByteArray> 0019 #include <QString> 0020 0021 #include <KIO/UDSEntry> 0022 0023 namespace KIO { 0024 class Job; 0025 } 0026 0027 class KJob; 0028 0029 class DefaultFileAccessJobHandler: public FileAccessJobHandler 0030 { 0031 Q_OBJECT 0032 public: 0033 using FileAccessJobHandler::FileAccessJobHandler; 0034 0035 FileAccessJobHandler* copy(FileAccess* inFileAccess) override { return new DefaultFileAccessJobHandler(inFileAccess);} 0036 0037 bool get(void* pDestBuffer, long maxLength) override; 0038 bool put(const void* pSrcBuffer, long maxLength, bool bOverwrite, bool bResume = false, qint32 permissions = -1) override; 0039 bool stat(bool bWantToWrite = false) override; 0040 bool copyFile(const QString& dest) override; 0041 bool rename(const FileAccess& dest) override; 0042 bool listDir(DirectoryList* pDirList, bool bRecursive, bool bFindHidden, 0043 const QString& filePattern, const QString& fileAntiPattern, 0044 const QString& dirAntiPattern, bool bFollowDirLinks, IgnoreList& ignoreList) override; 0045 0046 static bool mkDir(const QString& dirName) {return DefaultFileAccessJobHandler(nullptr).mkDirImp(dirName);} 0047 static bool rmDir(const QString& dirName) {return DefaultFileAccessJobHandler(nullptr).rmDirImp(dirName);} 0048 0049 bool removeFile(const QUrl& fileName) override; 0050 bool symLink(const QUrl& linkTarget, const QUrl& linkLocation) override; 0051 0052 private: 0053 bool mkDirImp(const QString& dirName) override; 0054 bool rmDirImp(const QString& dirName) override; 0055 0056 bool scanLocalDirectory(const QString& dirName, DirectoryList* dirList); 0057 0058 private Q_SLOTS: 0059 void slotJobEnded(KJob*); 0060 void slotStatResult(KJob*); 0061 void slotSimpleJobResult(KJob* pJob); 0062 void slotPutJobResult(KJob* pJob); 0063 0064 void slotGetData(KJob*, const QByteArray&); 0065 void slotPutData(KIO::Job*, QByteArray&); 0066 0067 void slotListDirProcessNewEntries(KIO::Job*, const KIO::UDSEntryList& l); 0068 }; 0069 0070 0071 0072 #endif /* FILEACCESSJOBHANDLER_H */