public override List <FileInfo> GetFileList() { try { var fileList = new List <FileInfo>(); if (IsCompressed) { fileList.Add(CompressedArchivePath); } else { fileList.AddRange(base.GetFileList()); DownloadFolder.Refresh(); if (DownloadFolder.Exists) { var downloadFiles = GetDownloadFiles(); var patchFiles = GetPatchFiles(); if (downloadFiles != null) { fileList.AddRange(downloadFiles); } if (patchFiles != null) { fileList.AddRange(patchFiles); } } WorkShopPath.Refresh(); if (WorkShopPath.Exists) { var workshopPath = GetWorkshopFiles(); fileList.AddRange(workshopPath); } FullAcfPath.Refresh(); if (FullAcfPath.Exists) { fileList.Add(FullAcfPath); } WorkShopPath.Refresh(); if (WorkShopAcfPath.Exists) { fileList.Add(WorkShopAcfPath); } } return(fileList); } catch (Exception ex) { Logger.Fatal(ex); return(null); } }
public List <FileInfo> GetFileList(bool includeDownloads = true, bool includeWorkshop = true) { try { List <FileInfo> FileList = new List <FileInfo>(); if (IsCompressed) { FileList.Add(CompressedArchiveName); } else { CommonFolder.Refresh(); if (CommonFolder.Exists) { FileList.AddRange(GetCommonFiles()); } DownloadFolder.Refresh(); if (includeDownloads && DownloadFolder.Exists) { FileList.AddRange(GetDownloadFiles()); FileList.AddRange(GetPatchFiles()); } WorkShopPath.Refresh(); if (includeWorkshop && WorkShopPath.Exists) { FileList.AddRange(GetWorkshopFiles()); } FullAcfPath.Refresh(); if (FullAcfPath.Exists) { FileList.Add(FullAcfPath); } WorkShopPath.Refresh(); if (WorkShopAcfPath.Exists) { FileList.Add(WorkShopAcfPath); } } return(FileList); } catch (Exception ex) { SLM.RavenClient.Capture(new SharpRaven.Data.SentryEvent(ex)); return(null); } }
public async Task <bool> DeleteFilesAsync(List.TaskInfo CurrentTask = null) { try { if (IsCompressed) { CompressedArchiveName.Refresh(); if (CompressedArchiveName.Exists) { await Task.Run(() => CompressedArchiveName.Delete()); } } else { List <FileInfo> FileList = GetFileList(); if (FileList.Count > 0) { Parallel.ForEach(FileList, currentFile => { try { CurrentTask?.mre.WaitOne(); currentFile.Refresh(); if (currentFile.Exists) { if (CurrentTask != null) { CurrentTask.mre.WaitOne(); CurrentTask.TaskStatusInfo = Framework.StringFormat.Format(Functions.SLM.Translate(nameof(Properties.Resources.TaskStatus_DeletingFile)), new { FileName = currentFile.Name, FormattedFileSize = Functions.FileSystem.FormatBytes(currentFile.Length) }); if (CurrentTask.ReportFileMovement) { Main.FormAccessor.TaskManager_Logs.Report($"[{DateTime.Now}] [{AppName}] {Framework.StringFormat.Format(Functions.SLM.Translate(nameof(Properties.Resources.TaskStatus_DeletingFile)), new { FileName = currentFile.Name, FormattedFileSize = Functions.FileSystem.FormatBytes(currentFile.Length) })}"); } } File.SetAttributes(currentFile.FullName, FileAttributes.Normal); currentFile.Delete(); } } catch (Exception ex) { Logger.Fatal(ex); } } ); } CommonFolder.Refresh(); // common folder, if exists if (CommonFolder.Exists) { await Task.Run(() => CommonFolder.Delete(true)); } DownloadFolder.Refresh(); // downloading folder, if exists if (DownloadFolder.Exists) { await Task.Run(() => DownloadFolder.Delete(true)); } WorkShopPath.Refresh(); // workshop folder, if exists if (WorkShopPath.Exists) { await Task.Run(() => WorkShopPath.Delete(true)); } FullAcfPath.Refresh(); // game .acf file if (FullAcfPath.Exists) { File.SetAttributes(FullAcfPath.FullName, FileAttributes.Normal); FullAcfPath.Delete(); } WorkShopAcfPath.Refresh(); // workshop .acf file if (WorkShopAcfPath.Exists) { File.SetAttributes(WorkShopAcfPath.FullName, FileAttributes.Normal); WorkShopAcfPath.Delete(); } if (CurrentTask != null) { CurrentTask.TaskStatusInfo = ""; } } return(true); } catch (FileNotFoundException ex) { Logger.Error(ex); return(true); } catch (DirectoryNotFoundException ex) { Logger.Error(ex); return(true); } catch (IOException ex) { Logger.Error(ex); return(true); } catch (UnauthorizedAccessException ex) { Logger.Error(ex); return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); Logger.Fatal(ex); return(false); } }
public List <FileInfo> GetFileList(bool includeDownloads = true, bool includeWorkshop = true) { try { var FileList = new List <FileInfo>(); if (IsCompressed) { FileList.Add(CompressedArchiveName); } else { CommonFolder.Refresh(); if (CommonFolder.Exists) { var commonFiles = GetCommonFiles(); if (commonFiles != null) { FileList.AddRange(commonFiles); } } DownloadFolder.Refresh(); if (includeDownloads && DownloadFolder.Exists) { var downloadFiles = GetDownloadFiles(); var patchFiles = GetPatchFiles(); if (downloadFiles != null) { FileList.AddRange(downloadFiles); } if (patchFiles != null) { FileList.AddRange(patchFiles); } } WorkShopPath.Refresh(); if (includeWorkshop && WorkShopPath.Exists) { var workshopPath = GetWorkshopFiles(); FileList.AddRange(workshopPath); } FullAcfPath.Refresh(); if (FullAcfPath.Exists) { FileList.Add(FullAcfPath); } WorkShopPath.Refresh(); if (WorkShopAcfPath.Exists) { FileList.Add(WorkShopAcfPath); } } return(FileList); } catch (Exception ex) { Logger.Fatal(ex); return(null); } }
public async void ParseMenuItemActionAsync(string action) { try { switch (action.ToLowerInvariant()) { default: if (string.IsNullOrEmpty(Properties.Settings.Default.SteamID64)) { return; } Process.Start(string.Format(action, AppID, Properties.Settings.Default.SteamID64)); break; case "compress": if (Functions.TaskManager.TaskList.Count(x => x.SteamApp == this && x.TargetLibrary == Library) == 0) { Functions.TaskManager.AddTask(new List.TaskInfo { SteamApp = this, TargetLibrary = Library, Compress = !IsCompressed, TaskType = Enums.TaskType.Compress }); } break; case "compact": if (Functions.TaskManager.TaskList.Count(x => x.SteamApp == this && x.TargetLibrary == Library && x.TaskType == Enums.TaskType.Compact) == 0) { Functions.TaskManager.AddTask(new List.TaskInfo { SteamApp = this, TargetLibrary = Library, TaskType = Enums.TaskType.Compact }); } break; case "disk": CommonFolder.Refresh(); if (CommonFolder.Exists) { Process.Start(CommonFolder.FullName); } break; case "acffile": FullAcfPath.Refresh(); if (FullAcfPath.Exists) { Process.Start(FullAcfPath.FullName); } break; case "deleteappfiles": await Task.Run(() => DeleteFilesAsync()); Library.Steam.Apps.Remove(this); Functions.SLM.Library.UpdateLibraryVisual(); if (SLM.CurrentSelectedLibrary == Library) { Functions.App.UpdateAppPanel(Library); } break; case "deleteappfilestm": Functions.TaskManager.AddTask(new List.TaskInfo { SteamApp = this, TargetLibrary = Library, TaskType = Enums.TaskType.Delete }); break; } } catch (Exception ex) { Logger.Fatal(ex); } }
public async Task <bool> DeleteFilesAsync(List.TaskInfo CurrentTask = null) { try { if (IsCompressed) { CompressedArchiveName.Refresh(); if (CompressedArchiveName.Exists) { await Task.Run(() => CompressedArchiveName.Delete()); } } else { List <FileInfo> FileList = GetFileList(); if (FileList.Count > 0) { Parallel.ForEach(FileList, currentFile => { try { CurrentTask?.mre.WaitOne(); currentFile.Refresh(); if (currentFile.Exists) { if (CurrentTask != null) { CurrentTask.mre.WaitOne(); CurrentTask.TaskStatusInfo = $"Deleting: {currentFile.Name} ({Functions.FileSystem.FormatBytes(currentFile.Length)})"; Main.FormAccessor.TaskManager_Logs.Add($"[{DateTime.Now}] [{CurrentTask.SteamApp.AppName}] Deleting file: {currentFile.FullName}"); } File.SetAttributes(currentFile.FullName, FileAttributes.Normal); currentFile.Delete(); } } catch (Exception ex) { logger.Fatal(ex); } } ); } CommonFolder.Refresh(); // common folder, if exists if (CommonFolder.Exists) { await Task.Run(() => CommonFolder.Delete(true)); } DownloadFolder.Refresh(); // downloading folder, if exists if (DownloadFolder.Exists) { await Task.Run(() => DownloadFolder.Delete(true)); } WorkShopPath.Refresh(); // workshop folder, if exists if (WorkShopPath.Exists) { await Task.Run(() => WorkShopPath.Delete(true)); } FullAcfPath.Refresh(); // game .acf file if (FullAcfPath.Exists) { File.SetAttributes(FullAcfPath.FullName, FileAttributes.Normal); FullAcfPath.Delete(); } WorkShopAcfPath.Refresh(); // workshop .acf file if (WorkShopAcfPath.Exists) { File.SetAttributes(WorkShopAcfPath.FullName, FileAttributes.Normal); WorkShopAcfPath.Delete(); } if (CurrentTask != null) { CurrentTask.TaskStatusInfo = ""; } } return(true); } catch (FileNotFoundException ex) { logger.Error(ex); return(true); } catch (DirectoryNotFoundException ex) { logger.Error(ex); return(true); } catch (IOException ex) { logger.Error(ex); return(true); } catch (UnauthorizedAccessException ex) { logger.Error(ex); return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); logger.Fatal(ex); await SLM.RavenClient.CaptureAsync(new SharpRaven.Data.SentryEvent(ex)); return(false); } }
public override async Task <bool> DeleteFilesAsync(List.TaskInfo CurrentTask = null) { try { if (IsCompressed) { CompressedArchivePath.Refresh(); if (CompressedArchivePath.Exists) { await Task.Run(() => CompressedArchivePath.Delete()).ConfigureAwait(false); } } else { await base.DeleteFilesAsync(); DownloadFolder.Refresh(); // downloading folder, if exists if (DownloadFolder.Exists) { await Task.Run(() => DownloadFolder.Delete(true)).ConfigureAwait(false); } WorkShopPath.Refresh(); // workshop folder, if exists if (WorkShopPath.Exists) { await Task.Run(() => WorkShopPath.Delete(true)).ConfigureAwait(false); } FullAcfPath.Refresh(); // game .acf file if (FullAcfPath.Exists) { File.SetAttributes(FullAcfPath.FullName, FileAttributes.Normal); FullAcfPath.Delete(); } WorkShopAcfPath.Refresh(); // workshop .acf file if (WorkShopAcfPath.Exists) { File.SetAttributes(WorkShopAcfPath.FullName, FileAttributes.Normal); WorkShopAcfPath.Delete(); } if (CurrentTask != null) { CurrentTask.TaskStatusInfo = ""; } } return(true); } catch (FileNotFoundException ex) { Logger.Error(ex); return(true); } catch (DirectoryNotFoundException ex) { Logger.Error(ex); return(true); } catch (IOException ex) { Logger.Error(ex); return(true); } catch (UnauthorizedAccessException ex) { Logger.Error(ex); return(true); } catch (Exception ex) { MessageBox.Show(ex.ToString()); Logger.Fatal(ex); return(false); } }
public async void ParseMenuItemActionAsync(string Action) { try { switch (Action.ToLowerInvariant()) { default: if (string.IsNullOrEmpty(SLM.UserSteamID64)) { return; } Process.Start(string.Format(Action, AppID, SLM.UserSteamID64)); break; case "disk": CommonFolder.Refresh(); if (CommonFolder.Exists) { Process.Start(CommonFolder.FullName); } break; case "acffile": FullAcfPath.Refresh(); if (FullAcfPath.Exists) { Process.Start(FullAcfPath.FullName); } break; case "deleteappfiles": await Task.Run(() => DeleteFilesAsync()); Library.Steam.Apps.Remove(this); Functions.SLM.Library.UpdateLibraryVisual(); if (SLM.CurrentSelectedLibrary == Library) { Functions.App.UpdateAppPanel(Library); } break; case "deleteappfilestm": Framework.TaskManager.AddTask(new List.TaskInfo { SteamApp = this, TargetLibrary = Library, TaskType = Enums.TaskType.Delete }); break; } } catch (Exception ex) { logger.Fatal(ex); } }