dedup/inc/fileindexer.h

30 lines
758 B
C++

#pragma once
#include <cstring>
#include <dirent.h>
#include <list>
#include <map>
#include <memory>
#include <set>
#include <string>
#include "searchfolder.h"
#include "file.h"
class FileIndexer {
public:
using map_t = std::multimap<uint64_t, std::shared_ptr<File>>;
map_t index(const SearchFolder& sf);
void setIgnoreDotFiles(bool b = true);
void setIgnoreInodeIDs(bool b = true);
private:
void handleFolderContent(dirent* dircont, const SearchFolder& sf, std::list<SearchFolder>& newfolders, map_t& newfiles);
void handleNewFile(ino_t inode, const std::string& path, map_t& newfiles);
std::set<uint64_t> knownInodes; // file inodes, that are known and should not be indexed again
bool ignoredotfiles = false;
bool ignoreInodeID = false;
};