//+--------------+ //| Transformers | //+--------------+ void Create_Path_If_It_Doesnt_Already_Exist(std::string const& path){ if (!File_Exists(path)){ execute_quietly(("mkdir -p " + path).c_str()); } return; }
void Root_Repo_Getter::Download_Root_Repo(Repository const& repo){ //make sure the repo exists in the local github. //if it's not there, it will be cloned there. //if it is there, it will updated to the most recent commit Repo_Getter::Store_Repo_Locally_From_Github(repo); if (!File_Exists(Current_Path() + "/" + repo.Repo_Name())) { execute_quietly("ln -s " + Path_Getter::Get_Local_Path_Of_Repo(repo) + " " + Current_Path()); } Step_Into_Folder(repo.Repo_Name()); return; }
void Copy_Folder_Contents_To_Path_Only_If_Contents_Are_Different(std::string folder_name, std::string directory_to_copy_to){ //get all the files we might want to copy over auto from_files = Recursively_Get_All_Paths_To_Files_From_Path(folder_name); //first element is the name of the directories. don't want that Remove_First_Element(from_files); //remove directories std::vector<std::string> new_from_files; for (auto & it: from_files){ if (!Is_Directory(it)){ new_from_files.push_back(it); } } //trim off the base directory names for (auto & it: new_from_files){ Remove_First_N_Chars(it,folder_name.size()+1); } //copy over only the files that have different content //if the file doesn't exist where we are copying it to, it will not be the same and thus copied over for (auto & it: new_from_files){ auto from_file = folder_name + "/" + it; auto to_file = directory_to_copy_to + "/" + it; if (!Files_Are_The_Same(from_file,to_file)){ Create_File_Even_If_The_Path_Doesnt_Exist(to_file); std::string command = std::string("cp -f ") + from_file + " " + to_file; //std::cout << command << std::endl; execute_quietly(command); } } }
void Create_The_Path_Empty_And_Step_Into_It(std::string const& path){ execute_quietly("rm -rf " + path); Create_Path_If_It_Doesnt_Already_Exist_And_Step_Into_It(path); return; }