-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathShow.cpp
39 lines (34 loc) · 974 Bytes
/
Show.cpp
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
//
// Created by Алексей on 2019-11-17.
//
#include "Show.h"
ModelResponse<> Show::handle(Request request) {
ModelResponse<> response;
response.module = ModelResponse<>::show;
std::vector<std::string> filenames;
try {
Archiver archiver(request.archive_path
);
auto files = archiver.Read();
for (auto file : files) {
filenames.emplace_back(file.name);
}
}
catch (std::invalid_argument& exept) {
response.state = ModelResponse<>::error;
response.info = exept.what();
return response;
}
catch(...) {
response.state = ModelResponse<>::error;
response.info = "Can't show files";
return response;
}
response.state = ModelResponse<>::ok;
response.info = "File(s) successfully showed";
response.data = filenames;
return response;
}
bool Show::can_handle(Request request) {
return request.type == Request::show;
}