aboutsummaryrefslogtreecommitdiff
path: root/qdeduper/filescanner.hpp
blob: 3c09192f15bc2a7c9ef7a34b24958002decc6598 (plain) (blame)
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
//Chris Xiong 2022
//License: MPL-2.0
#ifndef FILESCANNER_HPP
#define FILESCANNER_HPP

#include <atomic>
#include <filesystem>
#include <string>
#include <utility>
#include <vector>
#include <QObject>

namespace fs = std::filesystem;

class FileScanner : public QObject
{
    Q_OBJECT
    std::vector<std::string> mn;
    std::vector<std::pair<fs::path, bool>> paths;
    std::vector<fs::path> ret;
    std::size_t maxmnlen;
    std::atomic<bool> interrpt;
public:
    FileScanner();
    void add_magic_number(const std::string &m);
    void add_path(const fs::path &p, bool recurse = false);
    void scan();
    void interrupt();
    bool interrupted();
    std::vector<fs::path> file_list();
Q_SIGNALS:
    void scan_done_prep(std::size_t nfiles);
    void file_scanned(const fs::path &p, std::size_t n);
};

#endif