6namespace fs = std::filesystem;
8void Preprocessor::save_current_run_params(
string path){
9 vector<string> config_content;
11 string path_message = PATH_MESSAGE + path;
13 auto end = std::chrono::system_clock::now();
14 std::time_t end_time = std::chrono::system_clock::to_time_t(end);
15 string time_message = TIME_MESSAGE + std::ctime(&end_time);
17 config_content.push_back(path_message);
18 config_content.push_back(time_message);
23tuple<string,double,bool> Preprocessor::read_parameters(){
24 cout << INITIAL_MESSAGE <<
'\n';
25 string path,similarity_message;
27 cout << PROJECT_PATH_MESSAGE <<
'\n';
30 cout << MINIMUM_SIMILARITY_MESSAGE <<
'\n';
31 cin >> similarity_message;
32 double similarity = stod(similarity_message);
34 bool use_duplication_finder_by_tool=
false;
37 cout << MESSAGE_DUPLICATION_FINDER_TYPE_1 <<
'\n';
38 cout << MESSAGE_DUPLICATION_FINDER_TYPE_2 <<
'\n';
39 cout << MESSAGE_DUPLICATION_FINDER_TYPE_3 <<
'\n';
43 use_duplication_finder_by_tool =
true;
45 use_duplication_finder_by_tool =
false;
47 cout << INVALID_CODE_DUPLICATION_FINDER <<
'\n';
54 return {path,similarity,use_duplication_finder_by_tool};
57void Preprocessor::preprocess(
string path,
double similarity,
bool use_duplication_finder_by_tool){
58 cout << BREAKER_MESSAGE <<
'\n';
63 fs::path dir_to_remove = base_path;
64 if (fs::exists(dir_to_remove)) {
65 fs::remove_all(dir_to_remove);
68 string command_rm_tmp =
"rm -r -f " + base_path +
"/";
69 system(command_rm_tmp.c_str());
72 cout << DUPLICATION_MESSAGE <<
'\n';
74 if(use_duplication_finder_by_tool){
76 duplicationFinder.execute();
79 duplicationFinder.execute();
82 save_current_run_params(path);
84 cout << END_MESSAGE <<
'\n';
91 auto [path,similarity,use_duplication_finder_by_tool] = read_parameters();
92 preprocess(path,similarity,use_duplication_finder_by_tool);
100 preprocess(path,similarity,
true);
Singleton configuration manager class.
static Config * config()
Gets the singleton configuration instance.
string getBasePath()
Gets the current base path.
Code duplication preprocessor.
Main function extraction processor.
Preprocessor(bool force_preprocess)
Constructs preprocessor with optional forcing.
bool does_file_exist(string file_path)
Checks if a file exists at the given path.
void write_file_generic(string file_path, vector< string > content)
Writes content to a file at specified path.
Codebase preprocessing interface.