From cd052ea7837d406c8e9790b8d2f77d80e40098f3 Mon Sep 17 00:00:00 2001 From: Jaex Date: Mon, 15 Jun 2020 07:17:46 +0300 Subject: [PATCH] Rename create directory method --- ShareX.HelpersLib/Helpers/Helpers.cs | 12 ++++++------ ShareX.HelpersLib/Settings/SettingsBase.cs | 2 +- ShareX.HelpersLib/UpdateChecker/DownloaderForm.cs | 2 +- ShareX.MediaLib/VideoThumbnailer.cs | 2 +- ShareX/Program.cs | 13 ++++++++----- 5 files changed, 17 insertions(+), 14 deletions(-) diff --git a/ShareX.HelpersLib/Helpers/Helpers.cs b/ShareX.HelpersLib/Helpers/Helpers.cs index b55d67a77..3348d7d72 100644 --- a/ShareX.HelpersLib/Helpers/Helpers.cs +++ b/ShareX.HelpersLib/Helpers/Helpers.cs @@ -908,7 +908,7 @@ public static long GetFileSize(string path) return -1; } - public static void CreateDirectoryFromDirectoryPath(string directoryPath) + public static void CreateDirectory(string directoryPath) { if (!string.IsNullOrEmpty(directoryPath) && !Directory.Exists(directoryPath)) { @@ -930,7 +930,7 @@ public static void CreateDirectoryFromFilePath(string filePath) if (!string.IsNullOrEmpty(filePath)) { string directoryPath = Path.GetDirectoryName(filePath); - CreateDirectoryFromDirectoryPath(directoryPath); + CreateDirectory(directoryPath); } } @@ -955,7 +955,7 @@ public static string CopyFile(string filePath, string destinationFolder, bool ov { string fileName = Path.GetFileName(filePath); string destinationFilePath = Path.Combine(destinationFolder, fileName); - CreateDirectoryFromDirectoryPath(destinationFolder); + CreateDirectory(destinationFolder); File.Copy(filePath, destinationFilePath, overwrite); return destinationFilePath; } @@ -969,7 +969,7 @@ public static string MoveFile(string filePath, string destinationFolder, bool ov { string fileName = Path.GetFileName(filePath); string destinationFilePath = Path.Combine(destinationFolder, fileName); - CreateDirectoryFromDirectoryPath(destinationFolder); + CreateDirectory(destinationFolder); if (overwrite && File.Exists(destinationFilePath)) { @@ -1015,7 +1015,7 @@ public static string BackupFileWeekly(string filePath, string destinationFolder) if (!File.Exists(newFilePath)) { - CreateDirectoryFromDirectoryPath(destinationFolder); + CreateDirectory(destinationFolder); File.Copy(filePath, newFilePath, false); return newFilePath; } @@ -1035,7 +1035,7 @@ public static void BackupFileMonthly(string filePath, string destinationFolder) if (!File.Exists(newFilePath)) { - CreateDirectoryFromDirectoryPath(destinationFolder); + CreateDirectory(destinationFolder); File.Copy(filePath, newFilePath, false); } } diff --git a/ShareX.HelpersLib/Settings/SettingsBase.cs b/ShareX.HelpersLib/Settings/SettingsBase.cs index 40bdc81c1..dcc665708 100644 --- a/ShareX.HelpersLib/Settings/SettingsBase.cs +++ b/ShareX.HelpersLib/Settings/SettingsBase.cs @@ -161,7 +161,7 @@ private bool SaveInternal(string filePath) { string fileName = Path.GetFileName(filePath); backupFilePath = Path.Combine(BackupFolder, fileName); - Helpers.CreateDirectoryFromDirectoryPath(BackupFolder); + Helpers.CreateDirectory(BackupFolder); } File.Replace(tempFilePath, filePath, backupFilePath); diff --git a/ShareX.HelpersLib/UpdateChecker/DownloaderForm.cs b/ShareX.HelpersLib/UpdateChecker/DownloaderForm.cs index aa071a931..7c9104347 100644 --- a/ShareX.HelpersLib/UpdateChecker/DownloaderForm.cs +++ b/ShareX.HelpersLib/UpdateChecker/DownloaderForm.cs @@ -215,7 +215,7 @@ private void StartDownload() btnAction.Text = Resources.DownloaderForm_StartDownload_Cancel; string folderPath = Path.Combine(Path.GetTempPath(), "ShareX"); - Helpers.CreateDirectoryFromDirectoryPath(folderPath); + Helpers.CreateDirectory(folderPath); DownloadLocation = Path.Combine(folderPath, Filename); fileDownloader = new FileDownloader(URL, DownloadLocation, Proxy, AcceptHeader); diff --git a/ShareX.MediaLib/VideoThumbnailer.cs b/ShareX.MediaLib/VideoThumbnailer.cs index 312529345..d0d9ae88d 100644 --- a/ShareX.MediaLib/VideoThumbnailer.cs +++ b/ShareX.MediaLib/VideoThumbnailer.cs @@ -178,7 +178,7 @@ private string GetOutputDirectory() break; } - Helpers.CreateDirectoryFromDirectoryPath(directory); + Helpers.CreateDirectory(directory); return directory; } diff --git a/ShareX/Program.cs b/ShareX/Program.cs index 675a9fabe..d938eb001 100644 --- a/ShareX/Program.cs +++ b/ShareX/Program.cs @@ -474,11 +474,14 @@ private static void UpdatePersonalPath() private static void CreateParentFolders() { - Helpers.CreateDirectoryFromDirectoryPath(SettingManager.BackupFolder); - Helpers.CreateDirectoryFromDirectoryPath(ImageEffectsFolder); - Helpers.CreateDirectoryFromDirectoryPath(LogsFolder); - Helpers.CreateDirectoryFromDirectoryPath(ScreenshotsParentFolder); - Helpers.CreateDirectoryFromDirectoryPath(ToolsFolder); + if (Directory.Exists(PersonalFolder)) + { + Helpers.CreateDirectory(SettingManager.BackupFolder); + Helpers.CreateDirectory(ImageEffectsFolder); + Helpers.CreateDirectory(LogsFolder); + Helpers.CreateDirectory(ScreenshotsParentFolder); + Helpers.CreateDirectory(ToolsFolder); + } } private static void MigratePersonalPathConfig()