40 lines
874 B
C++
40 lines
874 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <dirent.h>
|
|
#include <map>
|
|
#include <memory>
|
|
|
|
#include "file.h"
|
|
#include "files.h"
|
|
#include "searchfolder.h"
|
|
|
|
class Dedup {
|
|
public:
|
|
Dedup();
|
|
~Dedup();
|
|
|
|
void addSearchFolder(const std::string& path, bool recurse = true);
|
|
|
|
void start();
|
|
|
|
private:
|
|
void indexFolder(const SearchFolder& sf);
|
|
void handleFolderContent(dirent* dircont, const SearchFolder& sf);
|
|
void handleNewFile(ino_t inode, const std::string& path);
|
|
Files& getFiles(uint64_t fs);
|
|
|
|
// all files that where found
|
|
std::map<uint64_t, Files> filesizes;
|
|
|
|
// files that where found ordered by inode (to detect deduplicated files)
|
|
std::map<ino_t, std::shared_ptr<File>> inodes;
|
|
|
|
// folders that should be scanned
|
|
std::vector<SearchFolder> folders;
|
|
|
|
bool hardlink = true;
|
|
bool ignoredotfiles = false;
|
|
uint64_t deduplicated = 0; // amount of bytes deduplicated
|
|
};
|