Browse Source

Fix project command cache clean when cache doesn't exist

Also add support for project paths that specify the full project name
Matt Benic 9 years ago
parent
commit
b70fb9c91f
2 changed files with 24 additions and 15 deletions
  1. 22 14
      Source/AtomicTool/AtomicTool.cpp
  2. 2 1
      Source/ToolCore/Command/ProjectCmd.cpp

+ 22 - 14
Source/AtomicTool/AtomicTool.cpp

@@ -230,27 +230,35 @@ void AtomicTool::Start()
     {
     {
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
 
 
-        String projectDirectory = cmd->GetProjectPath();
+        String projectPath = cmd->GetProjectPath();
             
             
         // default to current directly if command doesn't provide the path
         // default to current directly if command doesn't provide the path
-        if (!projectDirectory.Length())
-            projectDirectory = fileSystem->GetCurrentDir();
+        if (!projectPath.Length())
+            projectPath = fileSystem->GetCurrentDir();
 
 
-        Vector<String> projectFiles;
-        fileSystem->ScanDir(projectFiles, projectDirectory, "*.atomic", SCAN_FILES, false);
-        if (!projectFiles.Size())
+        String projectFile;
+        if (projectPath.EndsWith(".atomic", false))
         {
         {
-            ErrorExit(ToString("No .atomic project file in %s", projectDirectory.CString()));
-            return;
+            projectFile = projectPath;
+            projectPath = GetPath(projectPath);
         }
         }
-        else if (projectFiles.Size() > 1)
+        else
         {
         {
-            ErrorExit(ToString("Multiple .atomic project files found in %s", projectDirectory.CString()));
-            return;
+            Vector<String> projectFiles;
+            fileSystem->ScanDir(projectFiles, projectPath, "*.atomic", SCAN_FILES, false);
+            if (!projectFiles.Size())
+            {
+                ErrorExit(ToString("No .atomic project file in %s", projectPath.CString()));
+                return;
+            }
+            else if (projectFiles.Size() > 1)
+            {
+                ErrorExit(ToString("Multiple .atomic project files found in %s", projectPath.CString()));
+                return;
+            }
+            projectFile = projectPath + "/" + projectFiles[0];
         }
         }
 
 
-        String projectFile = projectDirectory + "/" + projectFiles[0];
-
         if (!tsystem->LoadProject(projectFile))
         if (!tsystem->LoadProject(projectFile))
         {
         {
             //ErrorExit(ToString("Failed to load project: %s", projectFile.CString()));
             //ErrorExit(ToString("Failed to load project: %s", projectFile.CString()));
@@ -258,7 +266,7 @@ void AtomicTool::Start()
         }
         }
 
 
         // Set the build path
         // Set the build path
-        String buildFolder = projectDirectory + "/" + "Build";
+        String buildFolder = projectPath + "/" + "Build";
         buildSystem->SetBuildPath(buildFolder);
         buildSystem->SetBuildPath(buildFolder);
 
 
         if (!fileSystem->DirExists(buildFolder))
         if (!fileSystem->DirExists(buildFolder))

+ 2 - 1
Source/ToolCore/Command/ProjectCmd.cpp

@@ -102,7 +102,8 @@ void ProjectCmd::HandleProjectBeginLoad(StringHash eventType, VariantMap& eventD
         cachePath = AddTrailingSlash(cachePath) + "Cache";
         cachePath = AddTrailingSlash(cachePath) + "Cache";
 
 
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
         FileSystem* fileSystem = GetSubsystem<FileSystem>();
-        if (!fileSystem->RemoveDir(cachePath, true))
+        if (fileSystem->DirExists(cachePath) &&
+            !fileSystem->RemoveDir(cachePath, true))
             Error("Cache clean failed");
             Error("Cache clean failed");
     }
     }
 }
 }