예제 #1
0
        /// <summary>Get the tagset to use to define the set of files to operate on</summary>
        /// <param name="Settings">The contents of the configuration file</param>
        /// <returns>The tagset that defines which files to operate on</returns>
        public static TagSet GetTagSet(DistillSettings Settings)
        {
            TagSet Tags =
                (
                    from TagSetDetail in Settings.TagSets
                    where TagSetDetail.Name == Options.TagSet
                    select TagSetDetail
                ).FirstOrDefault();

            if (Tags == null)
            {
                Error("Failed to find tagset: " + Options.TagSet);
                return(null);
            }

            Log(" ... using tagset " + Tags.Name + " with " + Tags.Tags.Length + " tags.", ConsoleColor.Cyan);
            return(Tags);
        }
예제 #2
0
		/// <summary>Gets the list of filesets with macros from the configuration file</summary>
		/// <param name="Settings">The contents of the configuration file</param>
		/// <param name="Set">The tagset to look for</param>
		/// <returns>A list of filesets including macros</returns>
		public static List<FileSet> GetFileSets( DistillSettings Settings, TagSet Set )
		{
			IEnumerable<FileSet[]> BaseSets =
			(
				from Group in Settings.FileGroups
				where Set.Tags.Contains( Group.Tag )
				where Group.Platform == null || Group.Platform.Contains( Options.Platform )
				select Group.Files
			);

			List<FileSet> Sets = new List<FileSet>();
			foreach( FileSet[] FileSet in BaseSets )
			{
				Sets.AddRange( FileSet );
			}

			return Sets;
		}
예제 #3
0
        /// <summary>Gets the list of filesets with macros from the configuration file</summary>
        /// <param name="Settings">The contents of the configuration file</param>
        /// <param name="Set">The tagset to look for</param>
        /// <returns>A list of filesets including macros</returns>
        public static List <FileSet> GetFileSets(DistillSettings Settings, TagSet Set)
        {
            IEnumerable <FileSet[]> BaseSets =
                (
                    from Group in Settings.FileGroups
                    where Set.Tags.Contains(Group.Tag)
                    where Group.Platform == null || Group.Platform.Contains(Options.Platform)
                    select Group.Files
                );

            List <FileSet> Sets = new List <FileSet>();

            foreach (FileSet[] FileSet in BaseSets)
            {
                Sets.AddRange(FileSet);
            }

            return(Sets);
        }
예제 #4
0
        /// <summary>The main entry point of the program</summary>
        /// <param name="Arguments">The arguments passed on on the commandline</param>
        /// <returns>Zero on success, non zero for failure</returns>
        private static int Main(string[] Arguments)
        {
            if (Arguments.Length == 0)
            {
                ShowUsage();
                return(1);
            }

            // Set the current directory to the root of the branch
            Environment.CurrentDirectory = Path.Combine(Environment.CurrentDirectory, "..", "..", "..");
            Options.Source      = Environment.CurrentDirectory;
            Options.Destination = Environment.CurrentDirectory;

            // Remember console color for restoring on exit
            ConsoleColor OriginalConsoleColor = Console.ForegroundColor;

            // Parse the command line for settings
            ParseArguments(Arguments);

            // Load the Distill.xml file and the game specific version
            string SettingsLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), Options.DistillSettings);

            if (File.Exists(SettingsLocation) == false)
            {
                Error("Unable to find distill file " + Options.DistillSettings);
                Console.ForegroundColor = OriginalConsoleColor;
                return(-1);
            }

            DistillSettings Settings = XmlHandler.ReadXml <DistillSettings>(SettingsLocation);

            // Find the known languages based on the folders in Engine Localization
            Settings.KnownLanguages = FindKnownLanguages();

            // Ensure the settings are valid
            if (!ValidateOptions(Settings))
            {
                Console.ForegroundColor = OriginalConsoleColor;
                return(-1);
            }

            // Get the set of tags we wish to copy
            TagSet Set = GetTagSet(Settings);

            if (Set == null)
            {
                Console.ForegroundColor = OriginalConsoleColor;
                return(-1);
            }

            // Get a list of filesets that includes all the unexpanded macros
            List <FileSet> DecoratedFileSets = GetFileSets(Settings, Set);

            if (DecoratedFileSets.Count == 0)
            {
                Error("No file sets for game, platform, tagset combination!");
                Console.ForegroundColor = OriginalConsoleColor;
                return(-1);
            }

            // Expand out all the macros
            List <FileSet> FileSets = ExpandMacros(DecoratedFileSets, Settings);
            // Get the files referenced by the filesets
            List <FileInfo> Files = GetFiles(FileSets);
            // Create a TOC
            TOC TableOfContents = new TOC(Files);

            Files = null;

            if (Options.bAuthenticate)
            {
                // If we're authenticating, compare the newly created TOC from files with the existing one on disk
                Authenticate(TableOfContents);
            }
            else
            {
                // Only write a TOC if we're copying locally to somewhere else (the most common case)
                string TOCFileName = Path.Combine(Options.Source, Options.Game, "TOC.xml");
                if (Options.bTOC && (Options.Source == Environment.CurrentDirectory))
                {
                    Log(" ... writing TOC: " + TOCFileName, ConsoleColor.Cyan);
                    XmlHandler.WriteXml <TOC>(TableOfContents, TOCFileName, "");
                }

                // Copy the TOC if it exists
                if (Options.bTOC)
                {
                    FileInfo TOCFileInfo = new FileInfo(TOCFileName);
                    if (TOCFileInfo.Exists)
                    {
                        TableOfContents.Entries.Add(new TOCEntry(TOCFileInfo));
                    }
                    else
                    {
                        Error(" ... Expected a TOC but there isn't one to copy: " + TOCFileName);
                    }
                }

                // Copy files
                ZipFiles(TableOfContents);
                CopyFiles(TableOfContents);
                FTPFiles(TableOfContents);

                Log("Distill process successful!", ConsoleColor.Green);
            }

            // Restore console color
            Console.ForegroundColor = OriginalConsoleColor;
            return(ErrorCode);
        }