diff --git a/Source/Editor/Editor.cpp b/Source/Editor/Editor.cpp index aa9f014ba..4da379fac 100644 --- a/Source/Editor/Editor.cpp +++ b/Source/Editor/Editor.cpp @@ -407,12 +407,26 @@ int32 Editor::LoadProduct() { Array projectFiles; FileSystem::DirectoryGetFiles(projectFiles, projectPath, TEXT("*.flaxproj"), DirectorySearchOption::TopDirectoryOnly); - if (projectFiles.Count() == 1) + if (projectFiles.Count() > 1) { - // Skip creating new project if it already exists - LOG(Info, "Skip creatinng new project because it already exists"); + 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) { 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);