+
+static Project WorkspaceGetFileOwner(char * absolutePath)
+{
+ Project owner = null;
+ for(prj : ide.workspace.projects)
+ {
+ if(prj.topNode.FindByFullPath(absolutePath, false))
+ {
+ owner = prj;
+ break;
+ }
+ }
+ if(!owner)
+ WorkspaceGetObjectFileNode(absolutePath, &owner);
+ return owner;
+}
+
+static ProjectNode WorkspaceGetObjectFileNode(char * filePath, Project * project)
+{
+ ProjectNode node = null;
+ char ext[MAX_EXTENSION];
+ GetExtension(filePath, ext);
+ if(ext[0])
+ {
+ IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+ if(type)
+ {
+ char fileName[MAX_FILENAME];
+ GetLastDirectory(filePath, fileName);
+ if(fileName[0])
+ {
+ DotMain dotMain = DotMain::FromFileName(fileName);
+ for(prj : ide.workspace.projects)
+ {
+ if((node = prj.FindNodeByObjectFileName(fileName, type, dotMain, null)))
+ {
+ if(project)
+ *project = prj;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return node;
+}
+
+static ProjectNode ProjectGetObjectFileNode(Project project, char * filePath)
+{
+ ProjectNode node = null;
+ char ext[MAX_EXTENSION];
+ GetExtension(filePath, ext);
+ if(ext[0])
+ {
+ IntermediateFileType type = IntermediateFileType::FromExtension(ext);
+ if(type)
+ {
+ char fileName[MAX_FILENAME];
+ GetLastDirectory(filePath, fileName);
+ if(fileName[0])
+ {
+ DotMain dotMain = DotMain::FromFileName(fileName);
+ node = project.FindNodeByObjectFileName(fileName, type, dotMain, null);
+ }
+ }
+ }
+ return node;
+}
+
+static void WorkspaceGetRelativePath(char * absolutePath, char * relativePath, Project * owner)
+{
+ Project prj = WorkspaceGetFileOwner(absolutePath);
+ if(owner)
+ *owner = prj;
+ if(!prj)
+ prj = ide.workspace.projects.firstIterator.data;
+ if(prj)
+ {
+ MakePathRelative(absolutePath, prj.topNode.path, relativePath);
+ MakeSlashPath(relativePath);
+ }
+ else
+ relativePath[0] = '\0';
+}
+
+static bool ProjectGetAbsoluteFromRelativePath(Project project, char * relativePath, char * absolutePath)
+{
+ ProjectNode node = project.topNode.FindWithPath(relativePath, false);
+ if(!node)
+ node = ProjectGetObjectFileNode(project, relativePath);
+ if(node)
+ {
+ strcpy(absolutePath, node.project.topNode.path);
+ PathCat(absolutePath, relativePath);
+ MakeSlashPath(absolutePath);
+ }
+ return node != null;
+}