-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (40 loc) · 1.29 KB
/
Copy pathmain.cpp
File metadata and controls
48 lines (40 loc) · 1.29 KB
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
#include <string.h>
#include <iostream>
#include <algorithm>
#include <wsjcpp_core.h>
#include <wsjcpp_diff_text.h>
int main(int argc, const char* argv[]) {
if (argc != 3) {
std::cout << "Usage: " << argv[0] << " file1 file2" << std::endl;
return -1;
}
std::string TAG = "MAIN";
std::string appName = std::string(WSJCPP_APP_NAME);
std::string appVersion = std::string(WSJCPP_APP_VERSION);
if (!WsjcppCore::dirExists(".logs")) {
WsjcppCore::makeDir(".logs");
}
WsjcppLog::setPrefixLogFile("wsjcpp-diff-text");
WsjcppLog::setLogDirectory(".logs");
std::string sFileName1(argv[1]);
std::string sFileName2(argv[2]);
if (!WsjcppCore::fileExists(sFileName1)) {
WsjcppLog::err(TAG, "file1 not found '" + sFileName1 + "'");
return -1;
}
if (!WsjcppCore::fileExists(sFileName2)) {
WsjcppLog::err(TAG, "file2 not found '" + sFileName2 + "'");
return -1;
}
std::string file_content1;
std::string file_content2;
WsjcppCore::readTextFile(sFileName1, file_content1);
WsjcppCore::readTextFile(sFileName2, file_content2);
std::vector<wsjcpp::diff_text_row> result;
wsjcpp::diff_text_compare(file_content1, file_content2, result);
for (int i = 0; i < result.size(); i++) {
std::cout << result[i].to_string() << std::endl;
}
result.clear();
return 0;
}