Advertisement
Guest User

Untitled

a guest
Aug 21st, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.82 KB | None | 0 0
  1. public bool Validate(string installDir, string dataDir, string backupDir, string logDir, string tempDir)
  2.     {
  3.       this._model.Model.Logger.Log("Validating Paths");
  4.       if (!string.IsNullOrEmpty(installDir))
  5.         this._model.Model.Logger.Log("installDir=" + installDir);
  6.       if (!string.IsNullOrEmpty(dataDir))
  7.         this._model.Model.Logger.Log("dataDir=" + dataDir);
  8.       if (!string.IsNullOrEmpty(backupDir))
  9.         this._model.Model.Logger.Log("backupDir=" + backupDir);
  10.       if (!string.IsNullOrEmpty(logDir))
  11.         this._model.Model.Logger.Log("logDir=" + logDir);
  12.       if (!string.IsNullOrEmpty(tempDir))
  13.         this._model.Model.Logger.Log("tempDir=" + tempDir);
  14.       if (this.RequiredDiskSpace.PackageCacheSize > 0UL)
  15.         this.AddFolderToDriveList(this._commonAppDataFolder, this.RequiredDiskSpace.PackageCacheSize);
  16.       if (this.RequiredDiskSpace.SystemSize > 0UL)
  17.         this.AddFolderToDriveList(this._systemFolder, this.RequiredDiskSpace.SystemSize);
  18.       if (this.RequiredDiskSpace.InstallDirSize > 0UL || !string.IsNullOrEmpty(installDir))
  19.       {
  20.         if (!this.ValidateInstallDir(installDir))
  21.           return false;
  22.         this.AddFolderToDriveList(installDir, this.RequiredDiskSpace.InstallDirSize);
  23.       }
  24.       if (this.RequiredDiskSpace.DataDirSize > 0UL || !string.IsNullOrEmpty(dataDir))
  25.       {
  26.         if (!this.ValidateDataDir(dataDir))
  27.           return false;
  28.         this.AddFolderToDriveList(dataDir, this.RequiredDiskSpace.DataDirSize);
  29.       }
  30.       if (this.RequiredDiskSpace.BackupDirSize > 0UL || !string.IsNullOrEmpty(backupDir))
  31.       {
  32.         if (!this.ValidateBackupDir(backupDir))
  33.           return false;
  34.         this.AddFolderToDriveList(backupDir, this.RequiredDiskSpace.BackupDirSize);
  35.       }
  36.       if (this.RequiredDiskSpace.LogDirSize > 0UL || !string.IsNullOrEmpty(logDir))
  37.       {
  38.         if (!this.ValidateLogDir(logDir))
  39.           return false;
  40.         this.AddFolderToDriveList(logDir, this.RequiredDiskSpace.LogDirSize);
  41.       }
  42.       if (this.RequiredDiskSpace.TempDirSize > 0UL || !string.IsNullOrEmpty(tempDir))
  43.       {
  44.         if (!this.ValidateTempDir(tempDir))
  45.           return false;
  46.         this.AddFolderToDriveList(tempDir, this.RequiredDiskSpace.TempDirSize);
  47.       }
  48.       foreach (DiskSpaceCalculator.InstallDrive installDrive in this.InstallDrives)
  49.       {
  50.         if (installDrive.RequiredSize > installDrive.FreeDiskSpace)
  51.         {
  52.           double num1 = (double) installDrive.RequiredSize / 1048576.0;
  53.           double num2 = (double) installDrive.FreeDiskSpace / 1048576.0;
  54.           string str1 = string.Format(this._model.LocalizationReader.GetString("General_MB"), (object) num1);
  55.           string str2 = string.Format(this._model.LocalizationReader.GetString("General_MB"), (object) num2);
  56.           if (num1 > 1024.0)
  57.           {
  58.             double num3 = num1 / 1024.0;
  59.             double num4 = num2 / 1024.0;
  60.             str1 = string.Format(this._model.LocalizationReader.GetString("General_GB"), (object) num3);
  61.             str2 = string.Format(this._model.LocalizationReader.GetString("General_GB"), (object) num4);
  62.           }
  63.           this.Message = string.Format(this._model.LocalizationReader.GetString("ErrorMessage_InvalidPath_NotEnoughDiskSpacce"), (object) installDrive.DriveName, (object) str1, (object) str2);
  64.           return false;
  65.         }
  66.       }
  67.       double num = (double) this.RequiredDiskSpace.TotalSize / 1048576.0;
  68.       string str = string.Format(this._model.LocalizationReader.GetString("General_MB"), (object) num);
  69.       if (num > 1024.0)
  70.         str = string.Format(this._model.LocalizationReader.GetString("General_GB"), (object) (num / 1024.0));
  71.       this.Message = string.Format(this._model.LocalizationReader.GetString("General_InstallSizeInformation"), (object) str);
  72.       return true;
  73.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement