Example #1
0
        /// Creates source group identified by sourceGroup, if needed, and returns it.
        /// If sourceGroup is empty or null, root group is returned
        private PBXGroupData CreateSourceGroup(string sourceGroup)
        {
            sourceGroup = Utils.FixSlashesInPath(sourceGroup);

            if (sourceGroup == null || sourceGroup == "")
            {
                return(GroupsGetMainGroup());
            }

            PBXGroupData gr = GroupsGetByProjectPath(sourceGroup);

            if (gr != null)
            {
                return(gr);
            }

            // the group does not exist -- create new
            gr = GroupsGetMainGroup();

            var    elements    = PBX.Utils.SplitPath(sourceGroup);
            string projectPath = null;

            foreach (string pathEl in elements)
            {
                if (projectPath == null)
                {
                    projectPath = pathEl;
                }
                else
                {
                    projectPath += "/" + pathEl;
                }

                PBXGroupData child = GetPBXGroupChildByName(gr, pathEl);
                if (child != null)
                {
                    gr = child;
                }
                else
                {
                    PBXGroupData newGroup = PBXGroupData.Create(pathEl, pathEl, PBXSourceTree.Group);
                    gr.children.AddGUID(newGroup.guid);
                    GroupsAdd(projectPath, gr, newGroup);
                    gr = newGroup;
                }
            }
            return(gr);
        }
Example #2
0
        private PBXGroupData CreateSourceGroup(string sourceGroup)
        {
            sourceGroup = PBXPath.FixSlashes(sourceGroup);
            if ((sourceGroup == null) || (sourceGroup == ""))
            {
                return(this.GroupsGetMainGroup());
            }
            PBXGroupData group = this.GroupsGetByProjectPath(sourceGroup);

            if (group == null)
            {
                group = this.GroupsGetMainGroup();
                string[] strArray    = PBXPath.Split(sourceGroup);
                string   projectPath = null;
                foreach (string str2 in strArray)
                {
                    if (projectPath == null)
                    {
                        projectPath = str2;
                    }
                    else
                    {
                        projectPath = projectPath + "/" + str2;
                    }
                    PBXGroupData pBXGroupChildByName = this.GetPBXGroupChildByName(group, str2);
                    if (pBXGroupChildByName != null)
                    {
                        group = pBXGroupChildByName;
                    }
                    else
                    {
                        PBXGroupData gr = PBXGroupData.Create(str2, str2, PBXSourceTree.Group);
                        group.children.AddGUID(gr.guid);
                        this.GroupsAdd(projectPath, group, gr);
                        group = gr;
                    }
                }
            }
            return(group);
        }