示例#1
0
        /// <summary>Generate a new list of filesets with all macros (e.g. %GAME%) expanded to their real values</summary>
        /// <param name="FileSets">List of filesets potentially containing macros</param>
        /// <param name="Settings">The settings used to fill in the macros</param>
        /// <returns>List of filesets with evaluated macros</returns>
        public static List <FileSet> ExpandMacros(List <FileSet> FileSets, DistillSettings Settings)
        {
            List <FileSet> NewFileSets = new List <FileSet>();

            Options.NotPlatforms = new List <string>(Settings.KnownPlatforms.Where(x => x.Name != Options.Platform && !Options.IncPlatforms.Contains(x.Name)).Select(x => x.Name));
            Options.NotLanguages = new List <string>(Settings.KnownLanguages.Where(x => x != Options.Region));

            foreach (FileSet OldFileSet in FileSets)
            {
                FileSet NewFileSet = new FileSet();

                NewFileSet.bIsRecursive = OldFileSet.bIsRecursive;
                NewFileSet.Path         = OldFileSet.Path;

                NewFileSet.Path = NewFileSet.Path.Replace("%GAME%", Options.Game);
                NewFileSet.Path = NewFileSet.Path.Replace("%PLATFORM%", Options.Platform);
                NewFileSet.Path = NewFileSet.Path.Replace("%LANGUAGE%", Options.Region);
                NewFileSet.Path = NewFileSet.Path.Replace("\\", "/");

                NewFileSet.FilterOutFiles   = ExpandFilterMacros(OldFileSet.FilterOutFiles);
                NewFileSet.FilterOutFolders = ExpandFilterMacros(OldFileSet.FilterOutFolders);

                if (NewFileSet.FilterOutFolders != null)
                {
                    List <string> NewFolders = new List <string>();
                    foreach (string FilterOutFolder in NewFileSet.FilterOutFolders)
                    {
                        string NewFilter = "/" + FilterOutFolder + "/";
                        NewFolders.Add(NewFilter);
                    }
                    NewFileSet.FilterOutFolders = NewFolders.ToArray();
                }

                NewFileSets.Add(NewFileSet);
            }

            Log(" ... found " + NewFileSets.Count + " file sets.", ConsoleColor.Cyan);
            return(NewFileSets);
        }
示例#2
0
        /// <summary>Generate a new list of filesets with all macros (e.g. %GAME%) expanded to their real values</summary>
        /// <param name="FileSets">List of filesets potentially containing macros</param>
        /// <param name="Settings">The settings used to fill in the macros</param>
        /// <returns>List of filesets with evaluated macros</returns>
        public static List<FileSet> ExpandMacros( List<FileSet> FileSets, DistillSettings Settings )
        {
            List<FileSet> NewFileSets = new List<FileSet>();

            Options.NotPlatforms = new List<string>( Settings.KnownPlatforms.Where( x => x.Name != Options.Platform && !Options.IncPlatforms.Contains(x.Name) ).Select( x => x.Name ) );
            Options.NotLanguages = new List<string>( Settings.KnownLanguages.Where( x => x != Options.Region ) );

            foreach( FileSet OldFileSet in FileSets )
            {
                FileSet NewFileSet = new FileSet();

                NewFileSet.bIsRecursive = OldFileSet.bIsRecursive;
                NewFileSet.Path = OldFileSet.Path;

                NewFileSet.Path = NewFileSet.Path.Replace( "%GAME%", Options.Game );
                NewFileSet.Path = NewFileSet.Path.Replace( "%PLATFORM%", Options.Platform );
                NewFileSet.Path = NewFileSet.Path.Replace( "%LANGUAGE%", Options.Region );
                NewFileSet.Path = NewFileSet.Path.Replace( "\\", "/" );

                NewFileSet.FilterOutFiles = ExpandFilterMacros(OldFileSet.FilterOutFiles);
                NewFileSet.FilterOutFolders = ExpandFilterMacros(OldFileSet.FilterOutFolders);

                if (NewFileSet.FilterOutFolders != null)
                {
                    List<string> NewFolders = new List<string>();
                    foreach (string FilterOutFolder in NewFileSet.FilterOutFolders)
                    {
                        string NewFilter = "/" + FilterOutFolder + "/";
                        NewFolders.Add(NewFilter);
                    }
                    NewFileSet.FilterOutFolders = NewFolders.ToArray();
                }

                NewFileSets.Add( NewFileSet );
            }

            Log( " ... found " + NewFileSets.Count + " file sets.", ConsoleColor.Cyan );
            return NewFileSets;
        }