-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
46 lines (35 loc) · 1019 Bytes
/
main.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
40
41
42
43
44
45
46
#include "wave2data.h"
int main(int argc, char* argv[]) {
std::string fn, output;
std::string data, new_data;
std::string sub("data");
auto ret = setopts(argc, argv, fn, output);
if (!ret) {
showHelp();
return 0;
} else if (fn.empty()) {
return 0;
}
// File Data (std::string)
data = file2string(fn);
// Data Check
if (!dataCheck(data, fn)) {
return 1;
}
// Search `data` string Position
auto subPos = data.find(sub);
if (subPos == static_cast<std::string::size_type>(std::string::npos)) {
std::cout << fn << ": Unknown Error" << std::endl;
return 0;
}
// Create New Split Data
auto new_size = getDataSize(data.substr(subPos+4, 4));
new_data = data.substr(subPos+8, new_size);
if (!createData(output, new_data)) {
return 1;
}
// Write Log
std::cout << "Data Size: " << new_size << std::endl;
std::cout << "Output: " << output << std::endl;
return 0;
}