Пример #1
0
bool Win32_Platform::Create_Directory(const char* path, bool recursive)
{
	if (recursive == true)
	{
		std::vector<std::string> cracked;
		std::string crack_path = "";

		Crack_Path(path, cracked);
		
		for (int i = 0; i < (int)cracked.size(); i++)
		{
			if (crack_path != "")
			{
				crack_path += "/";
			}
			crack_path += cracked.at(i);
			
			if (!Is_Directory(crack_path.c_str()))
			{
				bool result = Create_Directory(crack_path.c_str(), false);
				if (result == false)
				{
					return false;
				}
			}
		}

		return true;
	}
	else
	{
		int result = CreateDirectoryA(path, NULL);
		return (result != 0);
	}
}
bool File_Exists_And_Is_Directory(std::string path_to_file){
    if (File_Exists(path_to_file)){
        if (Is_Directory(path_to_file)){
            return true;
        }
    }
    return false;
}
Пример #3
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);
        }
    }
}