Example #1
0
        private void UpdateFramework()
        {
            using (var archive = ArchiveFactory.Current.OpenArchive(_installer))
            {
                long total = ArchiveFileHelper.GetSubTreeData(archive).BytesCount;
                uint uTotal = total > uint.MaxValue ? uint.MaxValue : (uint)total;
                Total = uTotal;

                var vfsUtils = new ArchiveFileHelper();
                vfsUtils.OnCopyProgress += (sender, e) => Progress += (uint)e.BytesCopied;

                foreach (var child in archive.Children)
                {
                    if (child.Value.IsFolder)
                    {
                        vfsUtils.CopyVfsSubtree(child.Value, EnvironmentSettings.Current.AppDirectory, false);
                    }
                    //can't overwrite the currently executing file
                    else if (child.Key.Equals("GamesManager.exe", StringComparison.InvariantCultureIgnoreCase))
                    {
                        vfsUtils.CopyVfsFile(child.Value, FileSystem.Combine(EnvironmentSettings.Current.AppDirectory, "GamesManager.New.exe"));
                    }
                    else
                    {
                        vfsUtils.CopyVfsFile(child.Value, FileSystem.Combine(EnvironmentSettings.Current.AppDirectory, child.Value.Name));
                    }
                }
            }
        }
Example #2
0
        private void UpdateFullGame(GameInstall installer)
        {
            IDirectory gameDir = FileSystem.Current.GetDirectory(Resources.GameBaseDir);
            if (!gameDir.Exists)
            {
                gameDir.Create();
            }

            IArchiveFile gameConfig = installer.GameContents.GetFile(Resources.GameConfig);
            IArchiveFile contentDir = installer.GameContents.GetFile(Resources.ContentDir);
            IArchiveFile binDir = installer.GameContents.GetFile(Resources.BinDir);
            IArchiveFile imageFile = null;
            if (installer.Game.GameIconData!=null)
            {
                imageFile = installer.GameContents.GetFile(Resources.GameIcon);
            }
            IArchiveFile gdfFile = installer.GameContents.GetFile(Resources.GameDefinitionFileBinary);
            IArchiveFile preferencesFile = installer.GameContents.GetFile(Resources.PreferencesConfig);

            var vfsUtils = new ArchiveFileHelper();

            var total = ArchiveFileHelper.GetSubTreeData(gameConfig).BytesCount;
            total += ArchiveFileHelper.GetSubTreeData(contentDir).BytesCount;
            total += ArchiveFileHelper.GetSubTreeData(binDir).BytesCount;
            total += ArchiveFileHelper.GetSubTreeData(imageFile).BytesCount;
            total += ArchiveFileHelper.GetSubTreeData(gdfFile).BytesCount;
            total += ArchiveFileHelper.GetSubTreeData(preferencesFile).BytesCount;

            uint uTotal = total > uint.MaxValue ? uint.MaxValue : (uint)total;
            Total = uTotal;

            vfsUtils.OnCopyProgress += (sender, e) => Progress += (uint) e.BytesCopied;

            vfsUtils.CopyVfsFile(gameConfig, FileSystem.Combine(Resources.GameBaseDir, Resources.GameConfig));

            if (contentDir != null)
            {
                vfsUtils.CopyVfsSubtree(contentDir, Resources.GameBaseDir, false);
            }

            if (binDir != null)
            {
                vfsUtils.CopyVfsSubtree(binDir, Resources.GameBaseDir, false);
            }

            if (imageFile != null)
            {
                vfsUtils.CopyVfsFile(imageFile, FileSystem.Combine(Resources.GameBaseDir, Resources.GameIcon));
                IconManager.Current.CreateIcon(installer.Game.Name, FileSystem.Combine(Resources.GameBaseDir, Resources.GameIcon), FileSystem.Combine(Resources.GameBaseDir, Resources.GameSystemIcon));
            }

            if (gdfFile!=null)
            {
                vfsUtils.CopyVfsFile(gdfFile, FileSystem.Combine(Resources.GameBaseDir, Resources.GameDefinitionFileBinary));
            }

            if (preferencesFile!=null)
            {
                vfsUtils.CopyVfsFile(preferencesFile, FileSystem.Combine(Resources.GameBaseDir, Resources.PreferencesConfig));
            }
        }