Example #1
0
        /// <summary>
        /// Download and open an remote TACT container
        /// <para>Note: This will download the entire CDN so will take a while</para>
        /// </summary>
        /// <param name="url"></param>
        /// <param name="tprDirectory"></param>
        /// <param name="product"></param>
        /// <param name="locale"></param>
        public void DownloadRemote(string tprDirectory, string product, Locale locale, bool systemFileOnly = false)
        {
            ManifestContainer = new Configs.ManifestContainer(product, locale);
            ManifestContainer.DownloadRemote(BaseDirectory);

            ConfigContainer = new Configs.ConfigContainer();
            ConfigContainer.DownloadRemote(tprDirectory, ManifestContainer);

            var cdnClient      = new CDNClient(ManifestContainer);
            var queuedDownload = new QueuedDownloader(tprDirectory, cdnClient);

            if (ConfigContainer.EncodingEKey.Value != null)
            {
                // Download encoding file
                var encodingEKey = DownloadSystemFile(ConfigContainer.EncodingEKey, cdnClient, tprDirectory);
                if (encodingEKey.Value != null)
                {
                    EncodingFile = new Encoding.EncodingFile(tprDirectory, encodingEKey, true);
                }

                // Download PatchFile
                DownloadSystemFile(ConfigContainer.PatchEKey, cdnClient, tprDirectory, "patch");

                // Download RootFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.RootCKey, out var ekeyEntry))
                {
                    ekeyEntry.EKeys.ForEach(x => queuedDownload.Enqueue(x.Value.ToString()));
                }

                // Download InstallFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.InstallCKey, out ekeyEntry))
                {
                    ekeyEntry.EKeys.ForEach(x => queuedDownload.Enqueue(x.Value.ToString()));
                }

                // Download DownloadFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadCKey, out ekeyEntry))
                {
                    ekeyEntry.EKeys.ForEach(x => queuedDownload.Enqueue(x.Value.ToString()));
                }

                // Download DownloadSizeFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadSizeCKey, out ekeyEntry))
                {
                    ekeyEntry.EKeys.ForEach(x => queuedDownload.Enqueue(x.Value.ToString()));
                }

                queuedDownload.Download("data");
            }

            // Download Indices and archives
            if (!systemFileOnly)
            {
                IndexContainer = new Indices.IndexContainer();
                IndexContainer.DownloadRemote(tprDirectory, ConfigContainer, ManifestContainer);
            }

            Open(tprDirectory);
        }
Example #2
0
        /// <summary>
        /// Download and open an remote TACT container
        /// <para>Note: This will download the entire CDN so will take a while</para>
        /// </summary>
        /// <param name="url"></param>
        /// <param name="directory"></param>
        /// <param name="product"></param>
        /// <param name="locale"></param>
        public void DownloadRemote(string directory, string product, Locale locale)
        {
            ConfigContainer = new Configs.ConfigContainer(product, locale);
            ConfigContainer.DownloadRemote(directory);

            var cdnClient      = new CDNClient(ConfigContainer);
            var queuedDownload = new QueuedDownloader(directory, cdnClient);

            if (ConfigContainer.EncodingEKey.Value != null)
            {
                // Download encoding file
                var encodingEKey = DownloadSystemFile(ConfigContainer.EncodingEKey, cdnClient, directory);
                if (encodingEKey.Value != null)
                {
                    EncodingFile = new Encoding.EncodingFile(BaseDirectory, encodingEKey, true);
                }

                // Download PatchFile
                DownloadSystemFile(ConfigContainer.PatchEKey, cdnClient, directory, "patch");

                // Download RootFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.RootCKey, out var ekeyEntry))
                {
                    queuedDownload.Enqueue(ekeyEntry.EKey.ToString());
                }

                // Download InstallFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.InstallCKey, out ekeyEntry))
                {
                    queuedDownload.Enqueue(ekeyEntry.EKey.ToString());
                }

                // Download DownloadFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadCKey, out ekeyEntry))
                {
                    queuedDownload.Enqueue(ekeyEntry.EKey.ToString());
                }

                // Download DownloadSizeFile
                if (EncodingFile.TryGetCKeyEntry(ConfigContainer.DownloadSizeCKey, out ekeyEntry))
                {
                    queuedDownload.Enqueue(ekeyEntry.EKey.ToString());
                }

                queuedDownload.Download("data");
            }

            // Download Indices and archives
            IndexContainer = new Indices.IndexContainer();
            IndexContainer.DownloadRemote(directory, ConfigContainer);

            Open(directory, product, locale);
        }
Example #3
0
        private async Task ExtractFiles(UnshippedBuild model, EncodingFile encoding)
        {
            var install = new InstallFile(Helpers.GetTempPath(model.Install));

            foreach (var file in install.Files)
            {
                if (!Helpers.HasAnyWildcard(file.FilePath, Consts.FileWildcards))
                {
                    continue;
                }
                if (!encoding.TryGetCKeyEntry(file.CKey, out var contentEntry))
                {
                    continue;
                }
                if (contentEntry.EKeys.Count == 0)
                {
                    continue;
                }

                var filepath = Path.Combine(Consts.TempDir, file.FilePath);
                Directory.CreateDirectory(Path.GetDirectoryName(filepath));

                // download the first one
                foreach (var ekey in contentEntry.EKeys)
                {
                    if (await DownloadFile(ekey.ToString(), filepath))
                    {
                        try
                        {
                            // decode file, using swap temp to avoid rw conflicts
                            BlockTableEncoder.DecodeAndExport(filepath, filepath + "_temp");
                            File.Copy(filepath + "_temp", filepath, true);
                        }
                        finally
                        {
                            File.Delete(filepath + "_temp");
                        }

                        // extract build info
                        if (file.FilePath.EndsWith(".exe") && File.Exists(filepath))
                        {
                            model.Build ??= FileVersionInfo.GetVersionInfo(filepath)?.FileVersion;
                            model.Product ??= Helpers.GetProductType(file.FilePath);
                        }

                        break;
                    }
                }
            }
        }