8#include <unordered_map>
18 using on_sync_progress_t = std::function<void(
size_t completed,
size_t total,
const std::string& current_job)>;
19 using on_entry_created_t = std::function<void(
const std::string&,
const fs::path&,
const std::vector<fs::path>&,
bool)>;
20 using on_entry_modified_t = std::function<void(
const std::string&,
const fs::path&,
const std::vector<fs::path>&,
bool)>;
21 using on_entry_removed_t = std::function<void(
const std::string&,
const fs::path&,
const std::vector<fs::path>&)>;
32 using mapping_t = std::unordered_map<std::string, mapping>;
47 const std::vector<std::string>& synced_ext,
66 void sync(
const fs::path& reference_dir,
const fs::path& synced_dir,
const on_sync_progress_t& on_progress =
nullptr);
77 auto get_mapping(
const std::string& ext) ->
mapping;
88 auto get_synced_directory(
const fs::path& path) -> fs::path;
96 auto get_synced_entries(
const fs::path& path,
bool is_directory) -> std::vector<fs::path>;
104 auto get_watch_path() -> fs::path;
111 fs::path reference_dir_;
113 fs::path synced_dir_;
115 std::atomic<std::uint64_t> watch_id_ = {0};
std::pair< fs::path, fs::path > rename_pair_t
std::function< void(const std::string &, const fs::path &, const std::vector< fs::path > &, bool)> on_entry_created_t
std::function< void(const std::string &, const fs::path &, const std::vector< fs::path > &, bool)> on_entry_modified_t
void unsync()
Stops syncing.
void sync(const fs::path &reference_dir, const fs::path &synced_dir, const on_sync_progress_t &on_progress=nullptr)
Start syncing the synced_dir with reference to the reference_dir i.e changes that occur in the refere...
void set_mapping(const std::string &ref_ext, const std::vector< std::string > &synced_ext, on_entry_created_t on_entry_created, on_entry_modified_t on_entry_modified, on_entry_removed_t on_entry_removed, on_entry_renamed_t on_entry_renamed)
Remaps a specific extension of the reference directory to extensions of the synced directory....
std::function< void(const std::string &, const rename_pair_t &, const std::vector< rename_pair_t > &)> on_entry_renamed_t
void set_directory_mapping(on_entry_created_t on_entry_created, on_entry_modified_t on_entry_modified, on_entry_removed_t on_entry_removed, on_entry_renamed_t on_entry_renamed)
std::unordered_map< std::string, mapping > mapping_t
std::function< void(const std::string &, const fs::path &, const std::vector< fs::path > &)> on_entry_removed_t
std::function< void(size_t completed, size_t total, const std::string ¤t_job)> on_sync_progress_t
std::vector< std::string > extensions
on_entry_removed_t on_entry_removed
on_entry_modified_t on_entry_modified
on_entry_renamed_t on_entry_renamed
on_entry_created_t on_entry_created