| 367 | } |
| 368 | |
| 369 | int32 Editor::LoadProduct() |
| 370 | { |
| 371 | PROFILE_MEM(Editor); |
| 372 | |
| 373 | // Flax Editor product |
| 374 | Globals::ProductName = TEXT("Flax Editor"); |
| 375 | Globals::CompanyName = TEXT("Flax"); |
| 376 | |
| 377 | #if FLAX_TESTS |
| 378 | // Flax Tests use auto-generated temporary project |
| 379 | CommandLine::Options.Project = Globals::TemporaryFolder / TEXT("Project"); |
| 380 | CommandLine::Options.NewProject = true; |
| 381 | #endif |
| 382 | |
| 383 | // Gather project directory from the command line |
| 384 | String projectPath = CommandLine::Options.Project.TrimTrailing(); |
| 385 | const int32 startIndex = projectPath.StartsWith('\"') || projectPath.StartsWith('\'') ? 1 : 0; |
| 386 | const int32 length = projectPath.Length() - (projectPath.EndsWith('\"') || projectPath.EndsWith('\'') ? 1 : 0) - startIndex; |
| 387 | if (length > 0) |
| 388 | { |
| 389 | projectPath = projectPath.Substring(startIndex, length - startIndex); |
| 390 | StringUtils::PathRemoveRelativeParts(projectPath); |
| 391 | if (FileSystem::IsRelative(projectPath)) |
| 392 | { |
| 393 | projectPath = Platform::GetWorkingDirectory() / projectPath; |
| 394 | StringUtils::PathRemoveRelativeParts(projectPath); |
| 395 | } |
| 396 | if (projectPath.EndsWith(TEXT(".flaxproj"))) |
| 397 | { |
| 398 | projectPath = StringUtils::GetDirectoryName(projectPath); |
| 399 | } |
| 400 | } |
| 401 | else |
| 402 | { |
| 403 | projectPath.Clear(); |
| 404 | } |
| 405 | |
| 406 | // Create new project option |
| 407 | if (CommandLine::Options.NewProject.IsTrue()) |
| 408 | { |
| 409 | Array<String> projectFiles; |
| 410 | FileSystem::DirectoryGetFiles(projectFiles, projectPath, TEXT("*.flaxproj"), DirectorySearchOption::TopDirectoryOnly); |
| 411 | if (projectFiles.Count() > 1) |
| 412 | { |
| 413 | Platform::Fatal(TEXT("Too many project files.")); |
| 414 | return -2; |
| 415 | } |
| 416 | else if (projectFiles.Count() == 1) |
| 417 | { |
| 418 | LOG(Info, "Skip creating new project because it already exists"); |
| 419 | CommandLine::Options.NewProject.Reset(); |
| 420 | } |
| 421 | else |
| 422 | { |
| 423 | Array<String> files; |
| 424 | FileSystem::DirectoryGetFiles(files, projectPath, TEXT("*"), DirectorySearchOption::TopDirectoryOnly); |
| 425 | if (files.Count() > 0) |
| 426 | { |
nothing calls this directly
no test coverage detected