Esempio n. 1
0
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);
        }
    }
}
Esempio n. 2
0
std::wstring& Remove_N_Chars_From_Front_And_Back(std::wstring & str, unsigned int const& number_of_times){
    return Remove_First_N_Chars(Remove_Last_N_Chars(str,number_of_times),number_of_times);
}