mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 17:52:45 +00:00 
			
		
		
		
	HackStudio: Ask to create a non-existent directory when making a project
Previously, if the parent directory didn't exist when making a project, it would say that the creation directory was 'invalid' which isn't necessarily true. This patch prompts the user to ask if they would like to create the parent directory when creating a project, instead of treating it as an 'invalid' directory.
This commit is contained in:
		
							parent
							
								
									5d0851cb0e
								
							
						
					
					
						commit
						cc1b2b95f7
					
				
					 1 changed files with 13 additions and 3 deletions
				
			
		|  | @ -154,9 +154,6 @@ Optional<String> NewProjectDialog::get_available_project_name() | ||||||
|     if (!s_project_name_validity_regex.has_match(chosen_name)) |     if (!s_project_name_validity_regex.has_match(chosen_name)) | ||||||
|         return {}; |         return {}; | ||||||
| 
 | 
 | ||||||
|     if (!Core::File::exists(create_in) || !Core::File::is_directory(create_in)) |  | ||||||
|         return {}; |  | ||||||
| 
 |  | ||||||
|     // Check for up-to 999 variations of the project name, in case it's already taken
 |     // Check for up-to 999 variations of the project name, in case it's already taken
 | ||||||
|     for (int i = 0; i < 1000; i++) { |     for (int i = 0; i < 1000; i++) { | ||||||
|         auto candidate = (i == 0) |         auto candidate = (i == 0) | ||||||
|  | @ -200,6 +197,19 @@ void NewProjectDialog::do_create_project() | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     auto create_in = m_create_in_input->text(); | ||||||
|  |     if (!Core::File::exists(create_in) || !Core::File::is_directory(create_in)) { | ||||||
|  |         auto result = GUI::MessageBox::show(this, String::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); | ||||||
|  |         if (result != GUI::MessageBox::ExecResult::ExecYes) | ||||||
|  |             return; | ||||||
|  | 
 | ||||||
|  |         auto created = Core::File::ensure_parent_directories(maybe_project_full_path.value()); | ||||||
|  |         if (!created) { | ||||||
|  |             GUI::MessageBox::show_error(this, String::formatted("Could not create directory {}", create_in)); | ||||||
|  |             return; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     auto creation_result = project_template->create_project(maybe_project_name.value(), maybe_project_full_path.value()); |     auto creation_result = project_template->create_project(maybe_project_name.value(), maybe_project_full_path.value()); | ||||||
|     if (!creation_result.is_error()) { |     if (!creation_result.is_error()) { | ||||||
|         // Successfully created, attempt to open the new project
 |         // Successfully created, attempt to open the new project
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Conor Byrne
						Conor Byrne