ide; fixed should not let you add the exact same files twice when there are exclusion...
authorRejean Loyer <rejean.loyer@gmail.com>
Mon, 6 May 2013 23:11:00 +0000 (19:11 -0400)
committerRejean Loyer <rejean.loyer@gmail.com>
Wed, 22 May 2013 11:33:01 +0000 (07:33 -0400)
- Calling FixupNode() before adding "Resources" node to fix crash this commit originally caused
- improved FindByFullPath performance

ide/src/project/Project.ec
ide/src/project/ProjectNode.ec
ide/src/project/ProjectView.ec

index 1055944..2db3a42 100644 (file)
@@ -4314,6 +4314,17 @@ Project LoadProject(char * filePath, char * activeConfigName)
             delete project.topNode.files;
             if(!project.files) project.files = { };
             project.topNode.files = project.files;
+
+            {
+               char topNodePath[MAX_LOCATION];
+               GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
+               MakeSlashPath(topNodePath);
+               PathCatSlash(topNodePath, filePath);
+               project.filePath = topNodePath;//filePath;
+            }
+
+            project.topNode.FixupNode(insidePath);
+
             project.resNode = project.topNode.Add(project, "Resources", project.topNode.files.last, resources, archiveFile, false);
             delete project.resNode.path;
             project.resNode.path = project.resourcesPath;
@@ -4325,15 +4336,7 @@ Project LoadProject(char * filePath, char * activeConfigName)
             project.resources = null;
             if(!project.configurations) project.configurations = { };
 
-            {
-               char topNodePath[MAX_LOCATION];
-               GetWorkingDir(topNodePath, sizeof(topNodePath)-1);
-               MakeSlashPath(topNodePath);
-               PathCatSlash(topNodePath, filePath);
-               project.filePath = topNodePath;//filePath;
-            }
-
-            project.topNode.FixupNode(insidePath);
+            project.resNode.FixupNode(insidePath);
          }
          delete parser;
       }
index ac73133..c9589b1 100644 (file)
@@ -982,6 +982,17 @@ private:
 
    ProjectNode FindByFullPath(char * path, bool includeResources)
    {
+      if(files)
+      {
+         char name[MAX_FILENAME];
+         GetLastDirectory(path, name);
+         return InternalFindByFullPath(path, includeResources, name);
+      }
+      return null;
+   }
+
+   ProjectNode InternalFindByFullPath(char * path, bool includeResources, char * lastDirName)
+   {
       ProjectNode result = null;
       if(files)
       {
@@ -989,7 +1000,9 @@ private:
          {
             if(includeResources || child.type != resources)
             {
-               if(child.type != folder && child.name)
+               if(child.type != file)
+                  result = child.InternalFindByFullPath(path, includeResources, lastDirName);
+               else if(child.name && !strcmpi(lastDirName, child.name))
                {
                   char p[MAX_LOCATION];
                   child.GetFullFilePath(p);
@@ -999,7 +1012,6 @@ private:
                      break;
                   }
                }
-               result = child.FindByFullPath(path, includeResources);
                if(result)
                   break;
             }
@@ -1093,51 +1105,54 @@ private:
    ProjectNode Add(Project project, char * filePath, ProjectNode after, NodeTypes type, NodeIcons icon, bool checkIfExists)
    {
       ProjectNode node = null;
-      char temp[MAX_LOCATION];
-      Map<Platform, SetBool> exclusionInfo { };
-
-      GetLastDirectory(filePath, temp);
-      //if(!checkIfExists || !project.topNode.Find(temp, false))
-      
-      // TOCHECK: Shouldn't this apply either for all configs or none?
-      CollectExclusionInfo(exclusionInfo, project.config);
-      if(!checkIfExists || !project.topNode.FindSameNameConflict(temp, false, exclusionInfo, project.config))
+      if(!project.topNode.FindByFullPath(filePath, true))
       {
-         // Do the check for folder in the same parent or resource files only here
-         if(type == folder || !checkIfExists)
+         char temp[MAX_LOCATION];
+         Map<Platform, SetBool> exclusionInfo { };
+
+         GetLastDirectory(filePath, temp);
+         //if(!checkIfExists || !project.topNode.Find(temp, false))
+
+         // TOCHECK: Shouldn't this apply either for all configs or none?
+         CollectExclusionInfo(exclusionInfo, project.config);
+         if(!checkIfExists || !project.topNode.FindSameNameConflict(temp, false, exclusionInfo, project.config))
          {
-            for(node : files)
+            // Do the check for folder in the same parent or resource files only here
+            if(type == folder || !checkIfExists)
             {
-               if(node.name && !strcmpi(node.name, temp))
-                  return null;
+               for(node : files)
+               {
+                  if(node.name && !strcmpi(node.name, temp))
+                     return null;
+               }
             }
-         }
 
-         node = ProjectNode { parent = this, indent = indent + 1, type = type, icon = icon, name = CopyString(temp) };
-         if(type != file)
-         {
-            node.files = { }; 
-            node.nodeType = folder;
-         }
-         if(type != folder)
-         {
-            if(filePath)
+            node = ProjectNode { parent = this, indent = indent + 1, type = type, icon = icon, name = CopyString(temp) };
+            if(type != file)
             {
-               StripLastDirectory(filePath, temp);
-               MakePathRelative(temp, project.topNode.path, temp);
-               node.path = CopyUnixPath(temp);
+               node.files = { };
+               node.nodeType = folder;
             }
-            node.nodeType = file;
-         }
-         else
-         {
-            strcpy(temp, (type == NodeTypes::project) ? "" : path);
-            PathCatSlash(temp, node.name);
-            node.path = CopyString(temp);
+            if(type != folder)
+            {
+               if(filePath)
+               {
+                  StripLastDirectory(filePath, temp);
+                  MakePathRelative(temp, project.topNode.path, temp);
+                  node.path = CopyUnixPath(temp);
+               }
+               node.nodeType = file;
+            }
+            else
+            {
+               strcpy(temp, (type == NodeTypes::project) ? "" : path);
+               PathCatSlash(temp, node.name);
+               node.path = CopyString(temp);
+            }
+            files.Insert(after, node);
          }
-         files.Insert(after, node);
+         delete exclusionInfo;
       }
-      delete exclusionInfo;
       return node;
    }
 
index 77eb3bf..a35a26c 100755 (executable)
@@ -28,7 +28,13 @@ class ImportFolderFSI : NormalFileSystemIterator
    bool OnFile(char * filePath)
    {
       ProjectNode parentNode = stack.lastIterator.data;
-      projectView.AddFile(parentNode, filePath, parentNode.isInResources, false);
+      if(!projectView.AddFile(parentNode, filePath, parentNode.isInResources, false))
+      {
+         char * msg = PrintString($"This file can't be imported due to a conflict.\n\n", filePath,
+               "\n\nThis occurs with identical file paths and with conflicting file names.\n");
+         MessageBox { master = ide, type = ok, text = "Import File Conflict", contents = msg }.Modal();
+         delete msg;
+      }
       return true;
    }
 }