Esempio n. 1
0
        private static async Task ExtractFiles(Configuration configuration, string tempFolder)
        {
            var presentationZip = Path.Combine(configuration.SteamInstallationPath, "assets", "presentation", "presentation.zip");
            var igpZip          = Path.Combine(configuration.SteamInstallationPath, "assets", "gamedb", "igp", "igp.zip");

            var presentationBackupZip = Path.Combine(configuration.SteamInstallationPath, "assets", "presentation", "presentation_bak.zip");
            var igpBackupZip          = Path.Combine(configuration.SteamInstallationPath, "assets", "gamedb", "igp", "igp_bak.zip");

            // In the instance we've already extracted these before, we will have renamed them
            if (!File.Exists(presentationZip))
            {
                presentationZip = presentationBackupZip;
            }

            if (!File.Exists(igpZip))
            {
                igpZip = igpBackupZip;
            }

            await QuickBMSUtility.ExtractFiles(presentationZip, tempFolder);

            await QuickBMSUtility.ExtractFiles(igpZip, tempFolder);

            // Only applicable if we haven't already changed the filename
            File.Move(presentationZip, presentationBackupZip);
            File.Move(igpZip, igpBackupZip);
        }
Esempio n. 2
0
        private async Task <InstallationStatus> QuickBMSExtract(ModAction <QuickBMSExtractAction> modAction, string tempFolder, bool autoUnpack)
        {
            foreach (var file in modAction.action.TargetFiles)
            {
                var physicalTargetPath = ResolvePath(file, modAction.mod, configuration);
                var fileInfo           = new FileInfo(physicalTargetPath);

                // Check if this has already been extracted
                if (extractedFiles.Contains(physicalTargetPath))
                {
                    continue;
                }

                if (!File.Exists(physicalTargetPath))
                {
                    throw new Exception($"Unable to find target path: {physicalTargetPath}");
                }

                await QuickBMSUtility.ExtractFiles(physicalTargetPath, tempFolder);

                // Move all extracted files into the root folder
                var newFolder = Path.Combine(tempFolder, Path.GetFileNameWithoutExtension(fileInfo.Name));
                var newFiles  = Directory.GetFiles(newFolder, "*", SearchOption.AllDirectories);

                extractedFiles.Add(physicalTargetPath);

                foreach (var newFile in newFiles)
                {
                    var targetPath = Path.Combine(fileInfo.Directory.FullName, newFile.Substring(newFolder.Length).TrimStart('\\').TrimStart('/'));
                    MoveFile_Internal(newFile, targetPath, modAction.mod);
                }

                if (autoUnpack && HasAutoMapping(physicalTargetPath, configuration, out var autoMapping))
                {
                    var autoUnpackActions = new ModActionCollection();
                    autoUnpackActions.AddActions(modAction.mod, autoMapping.Actions);

                    PerformActions(autoUnpackActions);
                }

                // Allow these files to be automatically deleted when finished with
                if (modAction.action.DeleteWhenComplete)
                {
                    DeleteFile_Internal(physicalTargetPath, modAction.mod);
                    deletedFiles.Add(physicalTargetPath);
                }
            }

            return(InstallationStatus.Success);
        }