From d5a6083a557eae64c98732623ea835e2db670580 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sun, 17 Dec 2023 12:47:46 +0100 Subject: [PATCH] Fix project initialization with `-new` if it already exists #2092 --- Source/Editor/Editor.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Source/Editor/Editor.cpp b/Source/Editor/Editor.cpp index 527bfeb6d..2cf9b9b8f 100644 --- a/Source/Editor/Editor.cpp +++ b/Source/Editor/Editor.cpp @@ -404,13 +404,23 @@ int32 Editor::LoadProduct() // Create new project option if (CommandLine::Options.NewProject) + { + Array projectFiles; + FileSystem::DirectoryGetFiles(projectFiles, projectPath, TEXT("*.flaxproj"), DirectorySearchOption::TopDirectoryOnly); + if (projectFiles.Count() == 1) + { + // Skip creating new project if it already exists + LOG(Info, "Skip creatinng new project because it already exists"); + CommandLine::Options.NewProject.Reset(); + } + } + if (CommandLine::Options.NewProject) { if (projectPath.IsEmpty()) projectPath = Platform::GetWorkingDirectory(); else if (!FileSystem::DirectoryExists(projectPath)) FileSystem::CreateDirectory(projectPath); FileSystem::NormalizePath(projectPath); - String folderName = StringUtils::GetFileName(projectPath); String tmpName; for (int32 i = 0; i < folderName.Length(); i++)