Exemplo n.º 1
0
 public string GetFileInstallationPath(string fileFullPath, ReleaseManifestFile.DeployMode deployMode, uint version)
 {
     if (deployMode == ReleaseManifestFile.DeployMode.Managed)
     {
         return(String.Format("{0}/managedfiles/{1}/{2}", GetFolder(), LeagueRADSInstallation.GetReleaseString(version), fileFullPath));
     }
     else if (deployMode == ReleaseManifestFile.DeployMode.Deployed4 || deployMode == ReleaseManifestFile.DeployMode.Deployed0)
     {
         return(String.Format("{0}/releases/{1}/deploy/{2}", GetFolder(), version, fileFullPath));
     }
     else
     {
         throw new UnsupportedDeployModeException();
     }
 }
        public void InstallFile(string gamePath, string filePath, LeagueRADSDeployRules deployRules)
        {
            FileInfo fileToInstall = new FileInfo(filePath);

            // Getting the matching file entry (null if new file)
            ReleaseManifestFileEntry fileEntry = this.GameManifest.GetFile(gamePath, false);

            // File is already installed, don't install it again
            byte[] fileMD5 = LeagueInstallation.CalculateMD5(filePath);
            if (fileEntry != null && fileEntry.MD5.SequenceEqual(fileMD5))
            {
                return;
            }

            // Finding the deploy mode to use
            ReleaseManifestFile.DeployMode deployMode = deployRules.GetTargetDeployMode(this.Project.Name, fileEntry);

            // Installing file
            string installPath = Project.GetFileInstallationPath(gamePath, deployMode, LeagueRADSInstallation.FantomeFilesVersion);

            Directory.CreateDirectory(Path.GetDirectoryName(installPath));
            if (fileEntry != null && (deployMode == ReleaseManifestFile.DeployMode.Deployed4 || deployMode == ReleaseManifestFile.DeployMode.Deployed0))
            {
                // Backup deployed file
                BackupFile(fileEntry, installPath);
            }

            File.Copy(filePath, installPath, true);

            // Setting manifest values
            if (fileEntry == null)
            {
                fileEntry = this.GameManifest.GetFile(gamePath, true);
            }
            fileEntry.MD5            = fileMD5;
            fileEntry.DeployMode     = deployMode;
            fileEntry.SizeRaw        = (int)fileToInstall.Length;
            fileEntry.SizeCompressed = fileEntry.SizeRaw;
            fileEntry.Version        = LeagueRADSInstallation.FantomeFilesVersion;
            this.HasChanged          = true;
        }
 private static bool HasToRestore(ReleaseManifestFile.DeployMode originalDeployMode, ReleaseManifestFile.DeployMode installedDeployedMode)
 {
     return((originalDeployMode == ReleaseManifestFile.DeployMode.Deployed4 || originalDeployMode == ReleaseManifestFile.DeployMode.Deployed0) &&
            (installedDeployedMode == ReleaseManifestFile.DeployMode.Deployed4 || installedDeployedMode == ReleaseManifestFile.DeployMode.Deployed0));
 }