File: parallel_scan.h

package info (click to toggle)
freefilesync 13.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,044 kB
  • sloc: cpp: 66,712; ansic: 447; makefile: 216
file content (54 lines) | stat: -rw-r--r-- 2,153 bytes parent folder | download | duplicates (3)
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
// *****************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under    *
// * GNU General Public License: https://www.gnu.org/licenses/gpl-3.0          *
// * Copyright (C) Zenju (zenju AT freefilesync DOT org) - All Rights Reserved *
// *****************************************************************************

#ifndef PARALLEL_SCAN_H_924588904275284572857
#define PARALLEL_SCAN_H_924588904275284572857

#include <map>
#include <set>
#include <chrono>
#include "path_filter.h"
#include "structures.h"
#include "file_hierarchy.h"
#include "process_callback.h"


namespace fff
{
struct DirectoryKey
{
    AbstractPath folderPath;
    FilterRef filter;
    SymLinkHandling handleSymlinks = SymLinkHandling::exclude;

    std::weak_ordering operator<=>(const DirectoryKey&) const = default;
};


struct DirectoryValue
{
    FolderContainer folderCont;

    //relative paths (or empty string for root) for directories that could not be read (completely), e.g. access denied, or temporary network drop
    std::unordered_map<Zstring, Zstringc /*error message*/> failedFolderReads;

    //relative paths (never empty) for failure to read single file/dir/symlink
    std::unordered_map<Zstring, Zstringc /*error message*/> failedItemReads;
};


//Attention: 1. ensure directory filtering is applied later to exclude filtered folders which have been kept as parent folders
//           2. remove folder aliases (e.g. case differences) *before* calling this function!!!

using TravErrorCb  = std::function<PhaseCallback::Response(const PhaseCallback::ErrorInfo& errorInfo)>;
using TravStatusCb = std::function<void(const std::wstring& statusLine, int itemsTotal)>;

std::map<DirectoryKey, DirectoryValue> parallelDeviceTraversal(const std::set<DirectoryKey>& foldersToRead,
                                                               const TravErrorCb& onError, const TravStatusCb& onStatusUpdate, //NOT optional
                                                               std::chrono::milliseconds cbInterval);
}

#endif //PARALLEL_SCAN_H_924588904275284572857