Esempio n. 1
0
        /// <summary>
        ///     Conducts the OpenSauce & HAC2 data backup routines.
        /// </summary>
        /// <param name="backupDir">
        ///     Backup directory to use for backing up OpenSauce & HAC2 data.
        /// </param>
        private void CommitBackups(string backupDir)
        {
            Directory.CreateDirectory(backupDir);
            var OSIDEbackupDir = Path.Combine(backupDir, OpenSauceDeveloper);

            new List <Move>
            {
                MoveFactory.Get(MoveFactory.Type.BackupOsFiles, _path, backupDir),
                MoveFactory.Get(MoveFactory.Type.BackupOsDirectories, _path, backupDir),
                MoveFactory.Get(MoveFactory.Type.BackupHac2Files, _path, backupDir)
            }.ForEach(move => move.Commit());

            if (Directory.Exists(Paths.KStudios))
            {
                Copy.All(Paths.KStudios, OSIDEbackupDir);
                try
                {
                    Directory.Delete(Paths.KStudios, true);
                }
                catch (UnauthorizedAccessException)
                {
                    /// <see cref="https://stackoverflow.com/a/31363010/14894786"/>
                    /// <seealso cref="https://stackoverflow.com/a/8055390/14894786"/>
                    var batPath = Path.Combine(Paths.Temp, "AdminDelKorn.bat");
                    var batText = "del /s /q \"Kornner Studios\" && rmdir /s /q \"Kornner Studios\"";
                    File.WriteAllText(batPath, batText);
                    new System.Diagnostics.ProcessStartInfo
                    {
                        FileName         = batPath,
                        Verb             = "RunAs",
                        WorkingDirectory = Paths.ProgData
                    };
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     If missing, copy the OpenSauceIDE from selected path to its home in Kornner Studios.<br/>
        ///     Needed by Install procedure.
        /// </summary>
        private void CopyOSIDE()
        {
            if (!Directory.Exists(Paths.KStudios))
            {
                throw new OpenSauceException("Kornner Studios directory not found.");
            }

            var local  = Path.Combine(_path, OpenSauceIDE);
            var global = Path.Combine(Paths.KStudios, OpenSauceDirectory, OpenSauceIDE);

            if (!Directory.Exists(global) && Directory.Exists(local))
            {
                Copy.All(local, global);
            }
        }
Esempio n. 3
0
        /// <summary>
        ///     Conducts optional installation finalisation routines.
        ///     - Restore the HCE shaders.
        ///     - Move the OpenSauce IDE.
        ///     - Backup directory cleanup.
        /// </summary>
        /// <param name="backupDir"></param>
        private void FinishInstall(string backupDir)
        {
            // restore backed up HCE shaders
            MoveFactory.Get(MoveFactory.Type.RestoreHceShaders, _path, backupDir).Commit();

            var source =
                Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
                             FileNames.OpenSauceDeveloper, FileNames.OpenSauceDirectory, FileNames.OpenSauceIDE);

            var target = Path.Combine(_path, FileNames.OpenSauceIDE);

            Copy.All(new DirectoryInfo(source), new DirectoryInfo(target));
            Directory.Delete(source, true);

            // cleans up backup directory
            if (!Directory.EnumerateFileSystemEntries(backupDir).Any())
            {
                Directory.Delete(backupDir);
            }
        }
Esempio n. 4
0
        /// <summary>
        ///     Conducts optional installation finalisation routines.
        ///     - Restore the HCE shaders.
        ///     - Move the OpenSauce IDE.
        ///     - Empty backup directory cleanup.
        /// </summary>
        /// <param name="backupDir"></param>
        private void FinishInstall(string backupDir)
        {
            // restore backed up HCE shaders
            MoveFactory.Get(MoveFactory.Type.RestoreHceShaders, _path, backupDir)
            .Commit();

            // copy OS IDE to Install path
            var source =
                Path.Combine(Paths.KStudios, OpenSauceDirectory, OpenSauceIDE);

            var target = Path.Combine(_path, OpenSauceIDE);

            Copy.All(source, target);

            // cleans up empty backup directory
            if (!Directory.EnumerateFileSystemEntries(backupDir).Any())
            {
                Directory.Delete(backupDir);
            }
        }
Esempio n. 5
0
        /// <summary>
        ///     Compiles a directory to a new Package instance.
        /// </summary>
        public void Compile()
        {
            try
            {
                Copy.All(Path, Combine(Paths.Temp, ArchiveName));
            }
            catch (IOException)
            {
                WriteWarn($"{Description} failed to compile new package.");
            }

            WriteInfo($"Verifying {Description} package.");
            var state = Verify();

            if (!state.IsValid)
            {
                WriteAndThrow(new PackageException(state.Reason));
            }

            WriteSuccess($"Package {Description} has been successfully verified.");
        }
Esempio n. 6
0
        /// <summary>
        ///     Applies the files in the package to the destination on the filesystem.
        /// </summary>
        /// <exception cref="PackageException">
        ///     Package archive does not exist.
        ///     - or -
        ///     Destination directory does not exist.
        /// </exception>
        public void Install()
        {
            WriteInfo($"Verifying {Description} package.");
            var state = Verify();

            if (!state.IsValid)
            {
                WriteAndThrow(new PackageException(state.Reason));
            }

            WriteSuccess($"Package {Description} has been successfully verified.");

            try
            {
                Copy.All(Combine(Paths.Temp, ArchiveName), Path);
            }
            catch (IOException)
            {
                WriteWarn($"{Description} data already exists. This is fine!");
            }

            WriteSuccess($"{Description} data has been installed successfully to the filesystem.");
        }