From 96f76fb14f64adc46702de5d374798a7dcb3ff7d Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 23 Mar 2024 15:37:05 +0200 Subject: [PATCH 1/3] Fix typos --- Source/Engine/Platform/Win32/Win32FileSystem.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Engine/Platform/Win32/Win32FileSystem.h b/Source/Engine/Platform/Win32/Win32FileSystem.h index 0af67e4bc..42ac5f4a1 100644 --- a/Source/Engine/Platform/Win32/Win32FileSystem.h +++ b/Source/Engine/Platform/Win32/Win32FileSystem.h @@ -16,12 +16,12 @@ class FLAXENGINE_API Win32FileSystem : public FileSystemBase public: // Creates a new directory - // @param path Drectory path + // @param path Directory path // @returns True if cannot create directory, otherwise false static bool CreateDirectory(const StringView& path); // Deletes an existing directory - // @param path Drectory path + // @param path Directory path // @param deleteSubdirectories True if delete all subdirectories and files, otherwise false // @returns True if cannot delete directory, otherwise false static bool DeleteDirectory(const String& path, bool deleteContents = true); @@ -32,15 +32,15 @@ public: static bool DirectoryExists(const StringView& path); // Finds the names of files (including their paths) that match the specified search pattern in the specified directory, using a value to determine whether to search subdirectories - // @param results When this metod completes, this list contains list of all filenames that match the specified search pattern + // @param results When this method completes, this list contains list of all filenames that match the specified search pattern // @param path Path of the directory to search in it - // @param searchPattern Custo msearch pattern to use during that operation - // @param option Addidtional search options + // @param searchPattern Custom search pattern to use during that operation + // @param option Additional search options // @returns True if an error occurred, otherwise false static bool DirectoryGetFiles(Array& results, const String& path, const Char* searchPattern, DirectorySearchOption option = DirectorySearchOption::AllDirectories); // Finds the names of directories (including their paths) that are inside the specified directory - // @param results When this metod completes, this list contains list of all filenames that match the specified search pattern + // @param results When this method completes, this list contains list of all filenames that match the specified search pattern // @param directory Path of the directory to search in it // @returns True if an error occurred, otherwise false static bool GetChildDirectories(Array& results, const String& directory); From 5633d1a18ab1751b992fbe324722490a70353c88 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sat, 23 Mar 2024 15:37:19 +0200 Subject: [PATCH 2/3] Prevent creating new project into non-empty folder --- Source/Editor/Editor.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Source/Editor/Editor.cpp b/Source/Editor/Editor.cpp index aa9f014ba..c4a08e825 100644 --- a/Source/Editor/Editor.cpp +++ b/Source/Editor/Editor.cpp @@ -406,12 +406,11 @@ int32 Editor::LoadProduct() if (CommandLine::Options.NewProject) { Array projectFiles; - FileSystem::DirectoryGetFiles(projectFiles, projectPath, TEXT("*.flaxproj"), DirectorySearchOption::TopDirectoryOnly); - if (projectFiles.Count() == 1) + FileSystem::DirectoryGetFiles(projectFiles, projectPath, TEXT("*"), DirectorySearchOption::TopDirectoryOnly); + if (projectFiles.Count() > 0) { - // Skip creating new project if it already exists - LOG(Info, "Skip creatinng new project because it already exists"); - CommandLine::Options.NewProject.Reset(); + Platform::Fatal(String::Format(TEXT("Target project folder '{0}' is not empty."), projectPath)); + return -1; } } if (CommandLine::Options.NewProject) From 07522823e5c789af728cee74a36e0c4332cc7135 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 24 Mar 2024 23:57:02 +0200 Subject: [PATCH 3/3] Restore opening existing projects with `-new` --- Source/Editor/Editor.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/Source/Editor/Editor.cpp b/Source/Editor/Editor.cpp index c4a08e825..4da379fac 100644 --- a/Source/Editor/Editor.cpp +++ b/Source/Editor/Editor.cpp @@ -406,11 +406,26 @@ int32 Editor::LoadProduct() if (CommandLine::Options.NewProject) { Array projectFiles; - FileSystem::DirectoryGetFiles(projectFiles, projectPath, TEXT("*"), DirectorySearchOption::TopDirectoryOnly); - if (projectFiles.Count() > 0) + FileSystem::DirectoryGetFiles(projectFiles, projectPath, TEXT("*.flaxproj"), DirectorySearchOption::TopDirectoryOnly); + if (projectFiles.Count() > 1) { - Platform::Fatal(String::Format(TEXT("Target project folder '{0}' is not empty."), projectPath)); - return -1; + Platform::Fatal(TEXT("Too many project files.")); + return -2; + } + else if (projectFiles.Count() == 1) + { + LOG(Info, "Skip creating new project because it already exists"); + CommandLine::Options.NewProject.Reset(); + } + else + { + Array files; + FileSystem::DirectoryGetFiles(files, projectPath, TEXT("*"), DirectorySearchOption::TopDirectoryOnly); + if (files.Count() > 0) + { + Platform::Fatal(String::Format(TEXT("Target project folder '{0}' is not empty."), projectPath)); + return -1; + } } } if (CommandLine::Options.NewProject)