-
Notifications
You must be signed in to change notification settings - Fork 1
/
directoryreader.h
66 lines (51 loc) · 1.64 KB
/
directoryreader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef DIRECTORYREADER_H
#define DIRECTORYREADER_H
#include <filesystem>
#include <QByteArray>
#include <QDir>
#include <QMap>
#include <QPair>
#include <QSet>
#include <QString>
#include <QRunnable>
#include <QAtomicInteger>
class QTreeWidgetItem;
class DirectoryReader: public QObject, public QRunnable
{
// NOLINTBEGIN
Q_OBJECT
// NOLINTEND
public:
DirectoryReader(std::filesystem::path dir,
QObject *parent = nullptr);
~DirectoryReader() override;
auto path() const -> std::filesystem::path;
[[nodiscard]] auto filter() const noexcept
-> QDir::Filters;
[[nodiscard]] auto readAttributes() const noexcept
-> bool;
auto isRunning() const noexcept -> bool;
auto isInterruptionRequested() const noexcept -> bool;
void requestInterruption();
void setFilter(QDir::Filters filters);
void setReadAttributes(bool value);
signals:
void entry(const std::filesystem::path &path,
const std::filesystem::file_status &status,
const QMap<QString, QByteArray> &attrs);
void ended(const std::filesystem::path &dir,
std::error_code ec,
const QSet<QString> &filenames);
private:
void run() override;
void read();
void read(const std::filesystem::directory_iterator &it);
auto read(const std::filesystem::directory_entry &dirEntry,
QSet<QString> &filenames) -> bool;
QAtomicInteger<bool> running{};
QAtomicInteger<bool> interrupt{};
std::filesystem::path directory;
QDir::Filters filters{QDir::Dirs|QDir::NoSymLinks};
bool readAttrs{true};
};
#endif // DIRECTORYREADER_H