/// <summary> /// Installs application using specified installation options. /// </summary> /// <param name="application">SteamApplication object.</param> /// <param name="installOptions">InstallOptions object.</param> /// <param name="filesSize">Size of files for installation. Method calculate this size if parameter equals to -1.</param> /// <param name="worker">BackgroundWorker object.</param> /// <returns>Size of installed files.</returns> private Int64 InstallApplication(SteamApplication application, InstallOptions installOptions, Int64 filesSize, BackgroundWorker worker) { Int64 copiedFilesSize = 0L; if (installOptions.FilesType != SteamDepotFileTypes.None) { SteamDepotFile[] files = application.GetFiles(installOptions); if (files != null) { DirectoryInfo destDirectory = new DirectoryInfo(installOptions.InstallPath); if (filesSize == -1L) filesSize = application.GetFilesSize(application, installOptions); foreach (SteamDepotFile file in files) { if (worker.CancellationPending) break; copiedFilesSize += SgiUtils.CopyFile(file, Path.Combine(destDirectory.FullName, file.RelativeName), filesSize, copiedFilesSize, worker); } } } if (filesSize == 0L) worker.ReportProgress(100); return copiedFilesSize; }
/// <summary> /// Returns size of application files in bytes for specified installation options. /// </summary> /// <param name="application">SteamApplication object.</param> /// <param name="installOptions">Installation options.</param> /// <returns>Size of application files in bytes for specified installation options.</returns> private Int64 GetFilesSize(SteamApplication application, InstallOptions installOptions) { Int64 size = 0L; if (installOptions.FilesType != SteamDepotFileTypes.None) { SteamDepotFile[] files = application.GetFiles(installOptions); if (files != null) { foreach (SteamDepotFile file in files) size += new FileInfo(file.FullName).Length; } } return size; }