/// <summary>
        ///   Adds the file.
        /// </summary>
        /// <param name = "groups">The groups.</param>
        /// <param name = "file">The file.</param>
        /// <param name = "sourceTree">The source tree.</param>
        /// <returns></returns>
        public PBXFileElement AddFile(String groups, String file, PBXSourceTree sourceTree)
        {
            lock (this.syncRoot) {
                // Prepare the group that will contain the file
                PBXGroup group = this.GetGroup (groups);
                PBXFileReference fileReference = null;
                PBXFileElement result = null;

                // Extract information
                String name = Path.GetFileName (file);
                String path = Path.GetFullPath (file);
                String rootDir = Path.GetFullPath (this.Dir);
                if (!String.IsNullOrEmpty(this.BaseDir)) {
                    rootDir = Path.Combine(rootDir, this.BaseDir);
                    rootDir = Path.GetFullPath (rootDir);
                }
                String parentDir = Path.GetDirectoryName (file);

                // If the file is localized, then add it to a variant group
                if (Path.GetExtension (parentDir).Equals (".lproj")) {
                    // The variant group may exists to search for it
                    PBXVariantGroup variantGroup = group.FindVariantGroup (name);
                    if (variantGroup == null) {
                        variantGroup = new PBXVariantGroup (name);
                        group.AddChild (variantGroup);
                    }

                    // The file is named like the language
                    name = Path.GetFileNameWithoutExtension (parentDir);
                    group = variantGroup;
                    result = variantGroup;
                }

                // Check if the file already exists
                fileReference = group.FindFileReference (name);
                if (fileReference == null) {
                    // Create a file reference
                    fileReference = new PBXFileReference (name);

                    // Set the source tree if none specified
                    if (sourceTree != PBXSourceTree.None) {
                        fileReference.SourceTree = sourceTree;
                    } else {
                        if (path.StartsWith (rootDir)) {
                            path = path.Substring (rootDir.Length + 1);
                            fileReference.SourceTree = PBXSourceTree.Group;
                        } else {
                            fileReference.SourceTree = PBXSourceTree.Absolute;
                        }
                    }
                    fileReference.Path = path;
                    fileReference.LastKnownFileType = GetFileType (file);

                    // Add it to the group
                    group.AddChild (fileReference);
                }

                return result ?? fileReference;
            }
        }
 public string AddFile(string path, string projectPath, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
     {
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     }
     return(this.AddFileImpl(path, projectPath, sourceTree, false));
 }
Beispiel #3
0
 // sourceTree must not be PBXSourceTree.Group
 public bool ContainsFileByRealPath(string path, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
     {
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     }
     return(FindFileGuidByRealPath(path, sourceTree) != null);
 }
Beispiel #4
0
 internal List <string> GetRealPathsRelativeToSourceTree(PBXSourceTree sourceTree)
 {
     if (this.m_RealPathToFileRefMap[sourceTree] != null)
     {
         return(new List <string>((IEnumerable <string>) this.m_RealPathToFileRefMap[sourceTree].Keys));
     }
     return((List <string>)null);
 }
Beispiel #5
0
        public static PBXFileReferenceData CreateFromFolderReference(string path, string projectFileName,
                                                                     PBXSourceTree tree)
        {
            var fileRef = CreateFromFile(path, projectFileName, tree);

            fileRef.m_LastKnownFileType = "folder";
            return(fileRef);
        }
 public PBXFileReferenceData FileRefsGetByRealPath(string path, PBXSourceTree sourceTree)
 {
     if (m_RealPathToFileRefMap[sourceTree].ContainsKey(path))
     {
         return(m_RealPathToFileRefMap[sourceTree][path]);
     }
     return(null);
 }
 // sourceTree must not be PBXSourceTree.Group
 public string AddFolderReference(string path, string projectPath, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
     {
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     }
     return(AddFileImpl(path, projectPath, sourceTree, true));
 }
Beispiel #8
0
        internal List <string> GetRealPathsRelativeToSourceTree(PBXSourceTree sourceTree)
        {
            if (m_RealPathToFileRefMap[sourceTree] != null)
            {
                return(new List <string>(m_RealPathToFileRefMap[sourceTree].Keys));
            }

            return(null);
        }
Beispiel #9
0
 // FIXME: ignores sourceTree at the moment
 public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree)
 {
     path = FixSlashesInPath(path);
     if (m_RealPathToFileRefMap[sourceTree].ContainsKey(path))
     {
         return(m_RealPathToFileRefMap[sourceTree][path].guid);
     }
     return(null);
 }
 // sourceTree must not be PBXSourceTree.Group
 public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     path = Utils.FixSlashesInPath(path);
     var fileRef = FileRefsGetByRealPath(path, sourceTree);
     if (fileRef != null)
         return fileRef.guid;
     return null;
 }
Beispiel #11
0
 public override void UpdateVars()
 {
     name = GetPropertyString("name");
     path = GetPropertyString("path");
     if (name == null)
         name = path;
     if (path == null)
         path = "";
     tree = FileTypeUtils.ParseSourceTree(GetPropertyString("sourceTree"));
 }
Beispiel #12
0
 public PBXFileReferenceData FileRefsGetByRealPath(string path, PBXSourceTree sourceTree)
 {
     //从PBXFileReference.txt中的数据取出对应的条目出来,从指定的key取出来。
     //m_RealPathToFileRefMap里的每个字典加起来就是m_ProjectPathToFileRefMap
     if (m_RealPathToFileRefMap[sourceTree].ContainsKey(path))
     {
         return(m_RealPathToFileRefMap[sourceTree][path]);
     }
     return(null);
 }
 public static PBXFileReferenceData CreateFromFile(string path, string projectFileName, PBXSourceTree tree)
 {
     string str = PBXGUID.Generate();
     PBXFileReferenceData data = new PBXFileReferenceData();
     data.SetPropertyString("isa", "PBXFileReference");
     data.guid = str;
     data.path = path;
     data.name = projectFileName;
     data.tree = tree;
     return data;
 }
Beispiel #14
0
 public static void CombinePaths(string path1, PBXSourceTree tree1, string path2, PBXSourceTree tree2,
                                 out string resPath, out PBXSourceTree resTree)
 {
     if (tree2 == PBXSourceTree.Group)
     {
         resPath = CombinePaths(path1, path2);
         resTree = tree1;
         return;
     }
     resPath = path2;
     resTree = tree2;
 }
Beispiel #15
0
 public static void Combine(string path1, PBXSourceTree tree1, string path2, PBXSourceTree tree2, out string resPath, out PBXSourceTree resTree)
 {
     if (tree2 == PBXSourceTree.Group)
     {
         resPath = PBXPath.Combine(path1, path2);
         resTree = tree1;
     }
     else
     {
         resPath = path2;
         resTree = tree2;
     }
 }
Beispiel #16
0
 public static PBXFileReference CreateFromFile(string path, string projectFileName,
                                               PBXSourceTree tree)
 {
     string guid = PBXGUID.Generate();
     
     PBXFileReference fileRef = new PBXFileReference();
     fileRef.SetPropertyString("isa", "PBXFileReference");
     fileRef.guid = guid;
     fileRef.path = path;
     fileRef.name = projectFileName;
     fileRef.tree = tree;
     return fileRef;
 }
Beispiel #17
0
        // name must not contain '/'
        public static PBXGroup Create(string name, string path, PBXSourceTree tree)
        {
            if (name.Contains("/"))
                throw new Exception("Group name must not contain '/'");

            PBXGroup gr = new PBXGroup();
            gr.guid = PBXGUID.Generate();
            gr.SetPropertyString("isa", "PBXGroup");
            gr.name = name;
            gr.path = path;
            gr.tree = PBXSourceTree.Group;
            gr.children = new GUIDList();

            return gr;
        }
Beispiel #18
0
        public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree)
        {
            path        = FixSlashesInPath(path);
            projectPath = FixSlashesInPath(projectPath);

            PBXGroup productGroup = CreateSourceGroup("Products");

            PBXFileReference fileRef = PBXFileReference.CreateFromFile(path, Path.GetFileName(projectPath),
                                                                       sourceTree);

            fileRefs.AddEntry(fileRef);
            CreateSourceGroup(GetDirectoryFromPath(projectPath)).AddGUID(fileRef.guid);

            project.project.AddReference(productGroup.guid, fileRef.guid);
        }
Beispiel #19
0
 public override void UpdateVars()
 {
     children = GetPropertyList("children");
     path     = GetPropertyString("path");
     name     = GetPropertyString("name");
     if (name == null)
     {
         name = path;
     }
     if (path == null)
     {
         path = "";
     }
     tree = FileTypeUtils.ParseSourceTree(GetPropertyString("sourceTree"));
 }
Beispiel #20
0
        public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree)
        {
            if (sourceTree == PBXSourceTree.Group)
            {
                throw new Exception("sourceTree must not be PBXSourceTree.Group");
            }
            path = PBXPath.FixSlashes(path);
            PBXFileReferenceData data = this.FileRefsGetByRealPath(path, sourceTree);

            if (data != null)
            {
                return(data.guid);
            }
            return(null);
        }
 public override void UpdateVars()
 {
     this.children = base.GetPropertyList("children");
     this.path = base.GetPropertyString("path");
     this.name = base.GetPropertyString("name");
     if (this.name == null)
     {
         this.name = this.path;
     }
     if (this.path == null)
     {
         this.path = "";
     }
     this.tree = FileTypeUtils.ParseSourceTree(base.GetPropertyString("sourceTree"));
 }
Beispiel #22
0
        // sourceTree must not be PBXSourceTree.Group
        public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree)
        {
            if (sourceTree == PBXSourceTree.Group)
            {
                throw new Exception("sourceTree must not be PBXSourceTree.Group");
            }
            path = PBXPath.FixSlashes(path);
            var fileRef = FileRefsGetByRealPath(path, sourceTree);

            if (fileRef != null)
            {
                return(fileRef.guid);
            }
            return(null);
        }
Beispiel #23
0
 public override void UpdateVars()
 {
     this.children = (GUIDList)this.GetPropertyList("children");
     this.path     = this.GetPropertyString("path");
     this.name     = this.GetPropertyString("name");
     if (this.name == null)
     {
         this.name = this.path;
     }
     if (this.path == null)
     {
         this.path = "";
     }
     this.tree = FileTypeUtils.ParseSourceTree(this.GetPropertyString("sourceTree"));
 }
Beispiel #24
0
        public static PBXVariantGroupData Create(string name, PBXSourceTree tree)
        {
            if (name.Contains("/"))
            {
                throw new Exception("Group name must not contain '/'");
            }

            PBXVariantGroupData gr = new PBXVariantGroupData();

            gr.guid = PBXGUID.Generate();
            gr.SetPropertyString("isa", "PBXVariantGroup");
            gr.name     = name;
            gr.tree     = PBXSourceTree.Group;
            gr.children = new GUIDList();
            return(gr);
        }
Beispiel #25
0
        public static PBXGroupData Create(string name, string path, PBXSourceTree tree)
        {
            if (name.Contains("/"))
            {
                throw new Exception("Group name must not contain '/'");
            }
            PBXGroupData pbxGroupData = new PBXGroupData();

            pbxGroupData.guid = PBXGUID.Generate();
            pbxGroupData.SetPropertyString("isa", "PBXGroup");
            pbxGroupData.name     = name;
            pbxGroupData.path     = path;
            pbxGroupData.tree     = PBXSourceTree.Group;
            pbxGroupData.children = new GUIDList();
            return(pbxGroupData);
        }
 public static PBXGroupData Create(string name, string path, PBXSourceTree tree)
 {
     if (name.Contains("/"))
     {
         throw new Exception("Group name must not contain '/'");
     }
     PBXGroupData data = new PBXGroupData {
         guid = PBXGUID.Generate()
     };
     data.SetPropertyString("isa", "PBXGroup");
     data.name = name;
     data.path = path;
     data.tree = PBXSourceTree.Group;
     data.children = new GUIDList();
     return data;
 }
Beispiel #27
0
 public override void UpdateVars()
 {
     name   = GetPropertyString("name");
     m_Path = GetPropertyString("path");
     if (name == null)
     {
         name = m_Path;
     }
     if (m_Path == null)
     {
         m_Path = "";
     }
     tree = FileTypeUtils.ParseSourceTree(GetPropertyString("sourceTree"));
     m_ExplicitFileType  = GetPropertyString("explicitFileType");
     m_LastKnownFileType = GetPropertyString("lastKnownFileType");
 }
Beispiel #28
0
 public override void UpdateVars()
 {
     this.name   = this.GetPropertyString("name");
     this.m_Path = this.GetPropertyString("path");
     if (this.name == null)
     {
         this.name = this.m_Path;
     }
     if (this.m_Path == null)
     {
         this.m_Path = "";
     }
     this.tree = FileTypeUtils.ParseSourceTree(this.GetPropertyString("sourceTree"));
     this.m_ExplicitFileType  = this.GetPropertyString("explicitFileType");
     this.m_LastKnownFileType = this.GetPropertyString("lastKnownFileType");
 }
Beispiel #29
0
        public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree)
        {
            if (sourceTree == PBXSourceTree.Group)
            {
                throw new Exception("sourceTree must not be PBXSourceTree.Group");
            }
            path        = PBXPath.FixSlashes(path);
            projectPath = PBXPath.FixSlashes(projectPath);
            PBXGroupData gr = PBXGroupData.CreateRelative("Products");

            this.GroupsAddDuplicate(gr);
            PBXFileReferenceData fileRef = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath), sourceTree);

            this.FileRefsAdd(path, projectPath, null, fileRef);
            this.CreateSourceGroup(PBXPath.GetDirectory(projectPath)).children.AddGUID(fileRef.guid);
            this.project.project.AddReference(gr.guid, fileRef.guid);
        }
        // sourceTree must not be PBXSourceTree.Group
        public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree)
        {
            if (sourceTree == PBXSourceTree.Group)
                throw new Exception("sourceTree must not be PBXSourceTree.Group");
            path = Utils.FixSlashesInPath(path);
            projectPath = Utils.FixSlashesInPath(projectPath);

            // note: we are duplicating products group for the project reference. Otherwise Xcode crashes.
            PBXGroupData productGroup = PBXGroupData.CreateRelative("Products");
            GroupsAddDuplicate(productGroup); // don't use GroupsAdd here

            PBXFileReferenceData fileRef = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath),
                                                                               sourceTree);
            FileRefsAdd(path, projectPath, null, fileRef);
            CreateSourceGroup(Utils.GetDirectoryFromPath(projectPath)).children.AddGUID(fileRef.guid);

            project.project.AddReference(productGroup.guid, fileRef.guid);
        }
Beispiel #31
0
        public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree)
        {
            path        = FixSlashesInPath(path);
            projectPath = FixSlashesInPath(projectPath);

            // note: we are duplicating products group for the project reference. Otherwise Xcode crashes.
            PBXGroup productGroup = PBXGroup.Create("Products");

            groups.AddEntry(productGroup); // don't use GroupsAdd here

            PBXFileReference fileRef = PBXFileReference.CreateFromFile(path, Path.GetFileName(projectPath),
                                                                       sourceTree);

            FileRefsAdd(path, projectPath, null, fileRef);
            CreateSourceGroup(GetDirectoryFromPath(projectPath)).AddGUID(fileRef.guid);

            project.project.AddReference(productGroup.guid, fileRef.guid);
        }
Beispiel #32
0
        public static PBXFileReference CreateFromFile(string path, string projectFileName,
                                                      PBXSourceTree tree)
        {
            string guid = PBXGUID.Generate();

            var fileRef = new PBXFileReference();

            fileRef.guid = guid;

            fileRef.path = path;
            fileRef.name = projectFileName;
            fileRef.text = String.Format("{{isa = PBXFileReference; lastKnownFileType = {0}; name = {1}; path = {2}; sourceTree = {3}; }}",
                                         FileTypeUtils.GetTypeName(Path.GetExtension(fileRef.name)),
                                         PBXStream.QuoteStringIfNeeded(fileRef.name),
                                         PBXStream.QuoteStringIfNeeded(fileRef.path),
                                         PBXStream.QuoteStringIfNeeded(FileTypeUtils.SourceTreeDesc(tree)));
            return(fileRef);
        }
Beispiel #33
0
        // The same file can be referred to by more than one project path.
        string AddFileImpl(string path, string projectPath, PBXSourceTree tree)
        {
            path        = FixSlashesInPath(path);
            projectPath = FixSlashesInPath(projectPath);

            string ext = Path.GetExtension(path);

            if (ext != Path.GetExtension(projectPath))
            {
                throw new Exception("Project and real path extensions do not match");
            }

            string guid = FindFileGuidByProjectPath(projectPath) ?? FindFileGuidByRealPath(path);

            if (guid == null)
            {
                PBXFileReference fileRef = PBXFileReference.CreateFromFile(path, GetFilenameFromPath(projectPath), tree);
                fileRefs.AddEntry(fileRef);
                CreateSourceGroup(GetDirectoryFromPath(projectPath)).AddGUID(fileRef.guid);
                guid = fileRef.guid;
            }
            return(guid);
        }
Beispiel #34
0
 public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
     {
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     }
     path = PBXPath.FixSlashes(path);
     projectPath = PBXPath.FixSlashes(projectPath);
     PBXGroupData gr = PBXGroupData.CreateRelative("Products");
     this.GroupsAddDuplicate(gr);
     PBXFileReferenceData fileRef = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath), sourceTree);
     this.FileRefsAdd(path, projectPath, null, fileRef);
     this.CreateSourceGroup(PBXPath.GetDirectory(projectPath)).children.AddGUID(fileRef.guid);
     this.project.project.AddReference(gr.guid, fileRef.guid);
 }
 public static PBXFileReferenceData CreateFromFolderReference(string path, string projectFileName, PBXSourceTree tree)
 {
     PBXFileReferenceData data = CreateFromFile(path, projectFileName, tree);
     data.m_LastKnownFileType = "folder";
     return data;
 }
Beispiel #36
0
 private string AddFileImpl(string path, string projectPath, PBXSourceTree tree, bool isFolderReference)
 {
     PBXFileReferenceData data;
     path = PBXPath.FixSlashes(path);
     projectPath = PBXPath.FixSlashes(projectPath);
     if (!isFolderReference && (Path.GetExtension(path) != Path.GetExtension(projectPath)))
     {
         throw new Exception("Project and real path extensions do not match");
     }
     string str = this.FindFileGuidByProjectPath(projectPath);
     if (str == null)
     {
         str = this.FindFileGuidByRealPath(path);
     }
     if (str != null)
     {
         return str;
     }
     if (isFolderReference)
     {
         data = PBXFileReferenceData.CreateFromFolderReference(path, PBXPath.GetFilename(projectPath), tree);
     }
     else
     {
         data = PBXFileReferenceData.CreateFromFile(path, PBXPath.GetFilename(projectPath), tree);
     }
     PBXGroupData parent = this.CreateSourceGroup(PBXPath.GetDirectory(projectPath));
     parent.children.AddGUID(data.guid);
     this.FileRefsAdd(path, projectPath, parent, data);
     return data.guid;
 }
        public static void CombinePaths(string path1, PBXSourceTree tree1, string path2, PBXSourceTree tree2,
                                        out string resPath, out PBXSourceTree resTree)
        {
            if (tree2 == PBXSourceTree.Group)
            {
                resPath = CombinePaths(path1, path2);
                resTree = tree1;
                return;
            }

            resPath = path2;
            resTree = tree2;
        }
Beispiel #38
0
        // sourceTree must not be PBXSourceTree.Group
        public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree)
        {
            if (sourceTree == PBXSourceTree.Group)
                throw new Exception("sourceTree must not be PBXSourceTree.Group");
            path = Utils.FixSlashesInPath(path);
            projectPath = Utils.FixSlashesInPath(projectPath);

            // note: we are duplicating products group for the project reference. Otherwise Xcode crashes.
            PBXGroupData productGroup = PBXGroupData.CreateRelative("Products");
            GroupsAddDuplicate(productGroup); // don't use GroupsAdd here

            PBXFileReferenceData fileRef = PBXFileReferenceData.CreateFromFile(path, Path.GetFileName(projectPath),
                                                                               sourceTree);
            FileRefsAdd(path, projectPath, null, fileRef);
            CreateSourceGroup(Utils.GetDirectoryFromPath(projectPath)).children.AddGUID(fileRef.guid);

            project.project.AddReference(productGroup.guid, fileRef.guid);
        }
Beispiel #39
0
 public string AddFolderReference(string path, string projectPath, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
     {
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     }
     return this.AddFileImpl(path, projectPath, sourceTree, true);
 }
Beispiel #40
0
 // sourceTree must not be PBXSourceTree.Group
 public string AddFile(string path, string projectPath, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     return AddFileImpl(path, projectPath, sourceTree, false);
 }
Beispiel #41
0
 public bool ContainsFileByRealPath(string path, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
     {
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     }
     return (this.FindFileGuidByRealPath(path, sourceTree) != null);
 }
Beispiel #42
0
 // sourceTree must not be PBXSourceTree.Group
 public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     path = Utils.FixSlashesInPath(path);
     var fileRef = FileRefsGetByRealPath(path, sourceTree);
     if (fileRef != null)
         return fileRef.guid;
     return null;
 }
 public bool ContainsFileByRealPath(string path, PBXSourceTree sourceTree)
 {
     return FindFileGuidByRealPath(path, sourceTree) != null;
 }
        // The same file can be referred to by more than one project path.
        private string AddFileImpl(string path, string projectPath, PBXSourceTree tree)
        {
            path = FixSlashesInPath(path);
            projectPath = FixSlashesInPath(projectPath);

            string ext = Path.GetExtension(path);
            if (ext != Path.GetExtension(projectPath))
                throw new Exception("Project and real path extensions do not match");

            string guid = FindFileGuidByProjectPath(projectPath);
            if (guid == null)
                guid = FindFileGuidByRealPath(path);
            if (guid == null)
            {
                PBXFileReference fileRef = PBXFileReference.CreateFromFile(path, GetFilenameFromPath(projectPath), tree);
                PBXGroup parent = CreateSourceGroup(GetDirectoryFromPath(projectPath));
                parent.AddGUID(fileRef.guid);
                FileRefsAdd(path, projectPath, parent, fileRef);
                guid = fileRef.guid;
            }
            return guid;
        }
 // FIXME: ignores sourceTree at the moment
 public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree)
 {
     path = FixSlashesInPath(path);
     if (m_RealPathToFileRefMap[sourceTree].ContainsKey(path))
         return m_RealPathToFileRefMap[sourceTree][path].guid;
     return null;
 }
Beispiel #46
0
        // The same file can be referred to by more than one project path.
        private string AddFileImpl(string path, string projectPath, PBXSourceTree tree, bool isFolderReference)
        {
            path = Utils.FixSlashesInPath(path);
            projectPath = Utils.FixSlashesInPath(projectPath);

            if (!isFolderReference && Path.GetExtension(path) != Path.GetExtension(projectPath))
                throw new Exception("Project and real path extensions do not match");

            string guid = FindFileGuidByProjectPath(projectPath);
            if (guid == null)
                guid = FindFileGuidByRealPath(path);
            if (guid == null)
            {
                PBXFileReferenceData fileRef;
                if (isFolderReference)
                    fileRef = PBXFileReferenceData.CreateFromFolderReference(path, Utils.GetFilenameFromPath(projectPath), tree);
                else
                    fileRef = PBXFileReferenceData.CreateFromFile(path, Utils.GetFilenameFromPath(projectPath), tree);
                PBXGroupData parent = CreateSourceGroup(Utils.GetDirectoryFromPath(projectPath));
                parent.children.AddGUID(fileRef.guid);
                FileRefsAdd(path, projectPath, parent, fileRef);
                guid = fileRef.guid;
            }
            return guid;
        }
        public static PBXFileReference CreateFromFile(string path, string projectFileName,
                                                      PBXSourceTree tree)
        {
            string guid = PBXGUID.Generate();

            PBXFileReference fileRef = new PBXFileReference();
            fileRef.guid = guid;

            fileRef.path = path;
            fileRef.name = projectFileName;
            fileRef.tree = tree;
            fileRef.text = String.Format("{{isa = PBXFileReference; lastKnownFileType = {0}; name = {1}; path = {2}; sourceTree = {3}; }}",
                                         FileTypeUtils.GetTypeName(Path.GetExtension(fileRef.name)),
                                         PBXStream.QuoteStringIfNeeded(fileRef.name),
                                         PBXStream.QuoteStringIfNeeded(fileRef.path),
                                         PBXStream.QuoteStringIfNeeded(FileTypeUtils.SourceTreeDesc(tree)));
            return fileRef;
        }
 public string AddFile(string path, string projectPath, PBXSourceTree sourceTree)
 {
     return AddFileImpl(path, projectPath, sourceTree);
 }
 internal static string SourceTreeDesc(PBXSourceTree tree)
 {
     return sourceTree[tree];
 }
 public override void UpdateVars()
 {
     this.name = base.GetPropertyString("name");
     this.m_Path = base.GetPropertyString("path");
     if (this.name == null)
     {
         this.name = this.m_Path;
     }
     if (this.m_Path == null)
     {
         this.m_Path = "";
     }
     this.tree = FileTypeUtils.ParseSourceTree(base.GetPropertyString("sourceTree"));
     this.m_ExplicitFileType = base.GetPropertyString("explicitFileType");
     this.m_LastKnownFileType = base.GetPropertyString("lastKnownFileType");
 }
Beispiel #51
0
 private PBXFileReferenceData FileRefsGetByRealPath(string path, PBXSourceTree sourceTree)
 {
     return this.m_Data.FileRefsGetByRealPath(path, sourceTree);
 }
        public void AddExternalProjectDependency(string path, string projectPath, PBXSourceTree sourceTree)
        {
            path = FixSlashesInPath(path);
            projectPath = FixSlashesInPath(projectPath);

            // note: we are duplicating products group for the project reference. Otherwise Xcode crashes.
            PBXGroup productGroup = PBXGroup.Create("Products");
            groups.AddEntry(productGroup); // don't use GroupsAdd here

            PBXFileReference fileRef = PBXFileReference.CreateFromFile(path, Path.GetFileName(projectPath),
                                                                       sourceTree);
            FileRefsAdd(path, projectPath, null, fileRef);
            CreateSourceGroup(GetDirectoryFromPath(projectPath)).AddGUID(fileRef.guid);

            project.project.AddReference(productGroup.guid, fileRef.guid);
        }
Beispiel #53
0
 internal static string SourceTreeDesc(PBXSourceTree tree)
 {
     return(sourceTree[tree]);
 }
Beispiel #54
0
 public string FindFileGuidByRealPath(string path, PBXSourceTree sourceTree)
 {
     if (sourceTree == PBXSourceTree.Group)
     {
         throw new Exception("sourceTree must not be PBXSourceTree.Group");
     }
     path = PBXPath.FixSlashes(path);
     PBXFileReferenceData data = this.FileRefsGetByRealPath(path, sourceTree);
     if (data != null)
     {
         return data.guid;
     }
     return null;
 }