44{
45 ScanReport report;
47
48 DiskReader reader;
49 std::string open_error;
50
53 trs(
"Opening source in read-only mode"),
54 0, 0, 0.01);
55
57 report.
logs.push_back(
trs(
"Error: could not open the source in read-only mode."));
58
59 if (!open_error.empty())
60 report.
logs.push_back(
trs(
"Open error:") + std::string(
" ") + open_error);
61
64 0,
65 0,
67 "DiskReader",
68 trs(
"Unable to open source") + (open_error.empty() ?
"" : std::string(
": ") + open_error),
69 1.0
70 });
71
75 0, 0, 1.0);
76
77 return report;
78 }
79
81
83 report.
logs.push_back(
trs(
"Source opened in read-only mode."));
84 if (!health.summary.empty()) {
85 report.
logs.push_back(
trs(
"Device health:") + std::string(
" ") + health.summary);
86 }
90 0,
91 0,
92 trs(
"Device health warning"),
93 trs(
"Device health probe"),
94 health.summary.empty() ?
trs(
"Device may be unstable or partially readable") : health.summary,
95 0.95
96 });
97 }
99 report.
logs.push_back(
trs(
"Input size:") + std::string(
" ") +
100 std::to_string(report.
input_size) +
" bytes");
101
103 report.
logs.push_back(
trs(
"Scan cancelled by user."));
104 return report;
105 }
106
108 trs(
"Partition analysis"),
110 0,
112 0.08);
113
115 report.
results.insert(report.
results.end(), mbr.begin(), mbr.end());
116
118 report.
logs.push_back(
trs(
"Scan cancelled during MBR parsing."));
119 return report;
120 }
121
123 trs(
"Partition analysis"),
125 0,
127 0.16);
128
130 report.
results.insert(report.
results.end(), gpt.begin(), gpt.end());
131
133 report.
logs.push_back(
trs(
"Scan cancelled during GPT parsing."));
134 return report;
135 }
136
139 trs(
"Searching filesystem signatures"),
142 0.36);
143
145 report.
results.insert(report.
results.end(), sig.begin(), sig.end());
146
148 report.
logs.push_back(
trs(
"Scan cancelled during signature scan."));
149 return report;
150 }
151
154 trs(
"Looking for lost partitions"),
157 0.62);
158
160 report.
results.insert(report.
results.end(), lost.begin(), lost.end());
161
163 report.
logs.push_back(
trs(
"Scan cancelled during lost partition search."));
164 return report;
165 }
166
168 trs(
"Filesystem probes"),
169 trs(
"Validating NTFS metadata"),
172 0.78);
173
175 report.
results.insert(report.
results.end(), ntfs.begin(), ntfs.end());
176
178 report.
logs.push_back(
trs(
"Scan cancelled during NTFS probe."));
179 return report;
180 }
181
183 trs(
"Filesystem probes"),
184 trs(
"Validating ext4, Btrfs, FAT32, exFAT"),
187 0.92);
188
190 report.
results.insert(report.
results.end(), fs.begin(), fs.end());
191
193 report.
logs.push_back(
trs(
"No useful results found."));
194 }
195
198 trs(
"Scan finished"),
201 1.0);
202
203 return report;
204}
static DeviceHealthReport probe(const std::string &device_path, CancelCallback cancel_cb={})
bool open_readonly(const std::string &path, std::string &error)
static std::vector< ScanResult > analyze(DiskReader &reader, const std::vector< ScanResult > &seed_results, std::vector< std::string > &logs)
static std::vector< ScanResult > find(DiskReader &reader, const std::vector< ScanResult > &known_results, std::vector< std::string > &logs)
static std::vector< ScanResult > analyze(DiskReader &reader, const std::vector< ScanResult > &seed_results, std::vector< std::string > &logs)
static std::vector< ScanResult > parse_mbr(DiskReader &reader, std::vector< std::string > &logs)
static std::vector< ScanResult > parse_gpt(DiskReader &reader, std::vector< std::string > &logs)
static std::vector< ScanResult > scan(DiskReader &reader, std::vector< std::string > &logs)
std::string trs(const char *msgid)
bool check_cancel(const std::function< bool()> &cancel_cb)
void emit_progress(const ScannerEngine::ProgressCallback &cb, const std::string &stage, const std::string &detail, uint64_t processed, uint64_t total, double fraction)
std::vector< ScanResult > results
std::vector< std::string > logs