Beispiel #1
0
        /// <summary>
        /// Adds a file to this project, ignoring dupes
        /// </summary>
        /// <param name="FilePath">Path to the file on disk</param>
        /// <param name="RelativeBaseFolder">The directory the path within the project will be relative to</param>
        public void AddFileToProject(string FilePath, string RelativeBaseFolder)
        {
            // Don't add duplicates
            SourceFile ExistingFile = null;

            if (SourceFileMap.TryGetValue(FilePath, out ExistingFile))
            {
                if (ExistingFile.RelativeBaseFolder != RelativeBaseFolder)
                {
                    if ((ExistingFile.RelativeBaseFolder != null) != (RelativeBaseFolder != null) ||
                        !ExistingFile.RelativeBaseFolder.Equals(RelativeBaseFolder, StringComparison.InvariantCultureIgnoreCase))
                    {
                        throw new BuildException("Trying to add file '" + FilePath + "' to project '" + ProjectFilePath + "' when the file already exists, but with a different relative base folder '" + RelativeBaseFolder + "' is different than the current file's '" + ExistingFile.RelativeBaseFolder + "'!");
                    }
                    else
                    {
                        throw new BuildException("Trying to add file '" + FilePath + "' to project '" + ProjectFilePath + "' when the file already exists, but the specified project relative base folder is different than the current file's!");
                    }
                }
            }
            else
            {
                SourceFile File = AllocSourceFile(FilePath, RelativeBaseFolder);
                if (File != null)
                {
                    SourceFileMap[FilePath] = File;
                    SourceFiles.Add(File);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Adds a file to this project, ignoring dupes
        /// </summary>
        /// <param name="FilePath">Path to the file on disk</param>
        /// <param name="BaseFolder">The directory the path within the project will be relative to</param>
        public void AddFileToProject(FileReference FilePath, DirectoryReference BaseFolder)
        {
            // Check if hasn't already been added as an aliased file
            if (AliasedFilesSet.Contains(FilePath))
            {
                return;
            }

            // Don't add duplicates
            SourceFile ExistingFile = null;

            if (SourceFileMap.TryGetValue(FilePath, out ExistingFile))
            {
                if (ExistingFile.BaseFolder != BaseFolder)
                {
                    throw new BuildException("Trying to add file '" + FilePath + "' to project '" + ProjectFilePath + "' when the file already exists, but with a different relative base folder '" + BaseFolder + "' is different than the current file's '" + ExistingFile.BaseFolder + "'!");
                }
            }
            else
            {
                SourceFile File = AllocSourceFile(FilePath, BaseFolder);
                if (File != null)
                {
                    SourceFileMap[FilePath] = File;
                    SourceFiles.Add(File);
                }
            }
        }