2017-10-22 17:03:02 +00:00
|
|
|
using System;
|
2016-11-02 18:09:29 +00:00
|
|
|
using System.Collections.Generic;
|
2013-08-20 19:28:46 +00:00
|
|
|
using System.IO;
|
2021-09-04 04:41:52 +00:00
|
|
|
using System.Linq;
|
2013-08-31 20:31:58 +00:00
|
|
|
using System.Text.RegularExpressions;
|
2017-01-04 02:36:47 +00:00
|
|
|
using NzbDrone.Common.Disk;
|
2013-03-30 21:29:02 +00:00
|
|
|
using NzbDrone.Common.EnsureThat;
|
2013-06-28 00:04:52 +00:00
|
|
|
using NzbDrone.Common.EnvironmentInfo;
|
2011-11-13 05:19:19 +00:00
|
|
|
|
2014-12-02 06:26:25 +00:00
|
|
|
namespace NzbDrone.Common.Extensions
|
2011-11-13 05:19:19 +00:00
|
|
|
{
|
2013-03-25 04:36:24 +00:00
|
|
|
public static class PathExtensions
|
2011-11-13 05:19:19 +00:00
|
|
|
{
|
2013-07-16 00:46:41 +00:00
|
|
|
private const string APP_CONFIG_FILE = "config.xml";
|
2017-09-18 03:25:28 +00:00
|
|
|
private const string DB = "sonarr.db";
|
2018-01-13 01:52:42 +00:00
|
|
|
private const string DB_RESTORE = "sonarr.restore";
|
2017-09-18 03:25:28 +00:00
|
|
|
private const string LOG_DB = "logs.db";
|
2013-07-24 15:08:31 +00:00
|
|
|
private const string NLOG_CONFIG_FILE = "nlog.config";
|
2021-07-30 04:47:53 +00:00
|
|
|
private const string UPDATE_CLIENT_EXE_NAME = "Sonarr.Update";
|
2013-04-30 00:04:14 +00:00
|
|
|
|
2017-09-18 03:25:28 +00:00
|
|
|
private static readonly string UPDATE_SANDBOX_FOLDER_NAME = "sonarr_update" + Path.DirectorySeparatorChar;
|
|
|
|
private static readonly string UPDATE_PACKAGE_FOLDER_NAME = "Sonarr" + Path.DirectorySeparatorChar;
|
|
|
|
private static readonly string UPDATE_BACKUP_FOLDER_NAME = "sonarr_backup" + Path.DirectorySeparatorChar;
|
|
|
|
private static readonly string UPDATE_BACKUP_APPDATA_FOLDER_NAME = "sonarr_appdata_backup" + Path.DirectorySeparatorChar;
|
|
|
|
private static readonly string UPDATE_CLIENT_FOLDER_NAME = "Sonarr.Update" + Path.DirectorySeparatorChar;
|
2013-04-30 00:04:14 +00:00
|
|
|
private static readonly string UPDATE_LOG_FOLDER_NAME = "UpdateLogs" + Path.DirectorySeparatorChar;
|
|
|
|
|
2019-01-05 23:20:52 +00:00
|
|
|
private static readonly Regex PARENT_PATH_END_SLASH_REGEX = new Regex(@"(?<!:)\\$", RegexOptions.Compiled);
|
|
|
|
|
2013-07-26 05:22:22 +00:00
|
|
|
public static string CleanFilePath(this string path)
|
2011-11-21 00:35:29 +00:00
|
|
|
{
|
2024-04-28 01:04:50 +00:00
|
|
|
if (path.IsNotNullOrWhiteSpace())
|
|
|
|
{
|
|
|
|
// Trim trailing spaces before checking if the path is valid so validation doesn't fail for something we can fix.
|
|
|
|
path = path.TrimEnd(' ');
|
|
|
|
}
|
|
|
|
|
2013-11-30 23:53:07 +00:00
|
|
|
Ensure.That(path, () => path).IsNotNullOrWhiteSpace();
|
2023-03-24 00:34:19 +00:00
|
|
|
Ensure.That(path, () => path).IsValidPath(PathValidationType.AnyOs);
|
2013-03-30 21:29:02 +00:00
|
|
|
|
2013-07-26 06:25:03 +00:00
|
|
|
var info = new FileInfo(path.Trim());
|
2011-11-21 00:35:29 +00:00
|
|
|
|
2022-11-07 00:44:13 +00:00
|
|
|
// UNC
|
2023-03-24 00:34:19 +00:00
|
|
|
if (!info.FullName.Contains('/') && info.FullName.StartsWith(@"\\"))
|
2011-11-21 00:35:29 +00:00
|
|
|
{
|
2024-04-28 01:04:50 +00:00
|
|
|
return info.FullName.TrimEnd('/', '\\');
|
2011-11-21 00:35:29 +00:00
|
|
|
}
|
|
|
|
|
2024-04-28 01:04:50 +00:00
|
|
|
return info.FullName.TrimEnd('/').Trim('\\');
|
2011-11-21 00:35:29 +00:00
|
|
|
}
|
|
|
|
|
2015-12-25 09:22:00 +00:00
|
|
|
public static bool PathNotEquals(this string firstPath, string secondPath, StringComparison? comparison = null)
|
|
|
|
{
|
|
|
|
return !PathEquals(firstPath, secondPath, comparison);
|
|
|
|
}
|
|
|
|
|
2015-06-13 07:42:16 +00:00
|
|
|
public static bool PathEquals(this string firstPath, string secondPath, StringComparison? comparison = null)
|
2013-08-20 19:28:46 +00:00
|
|
|
{
|
2015-06-13 07:42:16 +00:00
|
|
|
if (!comparison.HasValue)
|
|
|
|
{
|
2017-01-04 02:36:47 +00:00
|
|
|
comparison = DiskProviderBase.PathStringComparison;
|
2015-06-13 07:42:16 +00:00
|
|
|
}
|
|
|
|
|
2021-07-30 04:47:53 +00:00
|
|
|
if (firstPath.Equals(secondPath, comparison.Value))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2015-10-03 17:45:26 +00:00
|
|
|
return string.Equals(firstPath.CleanFilePath(), secondPath.CleanFilePath(), comparison.Value);
|
2014-04-19 15:09:22 +00:00
|
|
|
}
|
|
|
|
|
2020-08-10 21:56:46 +00:00
|
|
|
public static string GetPathExtension(this string path)
|
|
|
|
{
|
|
|
|
var idx = path.LastIndexOf('.');
|
|
|
|
if (idx == -1 || idx == path.Length - 1)
|
|
|
|
{
|
|
|
|
return string.Empty;
|
|
|
|
}
|
|
|
|
|
|
|
|
return path.Substring(idx);
|
|
|
|
}
|
|
|
|
|
2014-04-19 15:09:22 +00:00
|
|
|
public static string GetRelativePath(this string parentPath, string childPath)
|
|
|
|
{
|
|
|
|
if (!parentPath.IsParentPath(childPath))
|
|
|
|
{
|
2017-10-22 17:03:02 +00:00
|
|
|
throw new NotParentException("{0} is not a child of {1}", childPath, parentPath);
|
2014-04-19 15:09:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return childPath.Substring(parentPath.Length).Trim(Path.DirectorySeparatorChar);
|
|
|
|
}
|
|
|
|
|
2014-06-25 18:40:53 +00:00
|
|
|
public static string GetParentPath(this string childPath)
|
|
|
|
{
|
2024-07-28 23:57:54 +00:00
|
|
|
var path = new OsPath(childPath).Directory;
|
2019-01-01 23:01:24 +00:00
|
|
|
|
2024-07-28 23:57:54 +00:00
|
|
|
return path == OsPath.Null ? null : path.PathWithoutTrailingSlash;
|
2014-06-25 18:40:53 +00:00
|
|
|
}
|
|
|
|
|
2023-02-21 00:03:05 +00:00
|
|
|
public static string GetParentName(this string childPath)
|
|
|
|
{
|
2024-07-28 23:57:54 +00:00
|
|
|
var path = new OsPath(childPath).Directory;
|
2023-02-21 00:03:05 +00:00
|
|
|
|
2024-07-28 23:57:54 +00:00
|
|
|
return path == OsPath.Null ? null : path.Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetDirectoryName(this string childPath)
|
|
|
|
{
|
|
|
|
var path = new OsPath(childPath);
|
2023-02-21 01:20:07 +00:00
|
|
|
|
2024-07-28 23:57:54 +00:00
|
|
|
return path == OsPath.Null ? null : path.Name;
|
2023-02-21 00:03:05 +00:00
|
|
|
}
|
|
|
|
|
2019-08-04 01:55:31 +00:00
|
|
|
public static string GetCleanPath(this string path)
|
|
|
|
{
|
|
|
|
var cleanPath = OsInfo.IsWindows
|
|
|
|
? PARENT_PATH_END_SLASH_REGEX.Replace(path, "")
|
|
|
|
: path.TrimEnd(Path.DirectorySeparatorChar);
|
|
|
|
|
|
|
|
return cleanPath;
|
|
|
|
}
|
|
|
|
|
2014-04-19 15:09:22 +00:00
|
|
|
public static bool IsParentPath(this string parentPath, string childPath)
|
|
|
|
{
|
2024-07-28 23:57:54 +00:00
|
|
|
var parent = new OsPath(parentPath);
|
|
|
|
var child = new OsPath(childPath);
|
2014-04-19 15:09:22 +00:00
|
|
|
|
2024-07-28 23:57:54 +00:00
|
|
|
while (child.Directory != OsPath.Null)
|
2013-08-21 01:17:06 +00:00
|
|
|
{
|
2024-07-28 23:57:54 +00:00
|
|
|
if (child.Directory.Equals(parent, true))
|
2014-04-19 15:09:22 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2024-07-28 23:57:54 +00:00
|
|
|
child = child.Directory;
|
2013-08-21 01:17:06 +00:00
|
|
|
}
|
2013-08-20 19:28:46 +00:00
|
|
|
|
2014-04-19 15:09:22 +00:00
|
|
|
return false;
|
2013-08-20 19:28:46 +00:00
|
|
|
}
|
|
|
|
|
2013-08-31 20:43:35 +00:00
|
|
|
private static readonly Regex WindowsPathWithDriveRegex = new Regex(@"^[a-zA-Z]:\\", RegexOptions.Compiled);
|
2013-08-31 20:31:58 +00:00
|
|
|
|
2023-03-24 00:34:19 +00:00
|
|
|
public static bool IsPathValid(this string path, PathValidationType validationType)
|
2013-08-31 20:31:58 +00:00
|
|
|
{
|
2023-08-13 21:03:18 +00:00
|
|
|
if (string.IsNullOrWhiteSpace(path) || path.ContainsInvalidPathChars())
|
2013-08-31 20:31:58 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2013-08-31 20:43:35 +00:00
|
|
|
|
2024-04-28 01:04:50 +00:00
|
|
|
if (path.Trim() != path)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
var directoryInfo = new DirectoryInfo(path);
|
|
|
|
|
|
|
|
while (directoryInfo != null)
|
|
|
|
{
|
|
|
|
if (directoryInfo.Name.Trim() != directoryInfo.Name)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
directoryInfo = directoryInfo.Parent;
|
|
|
|
}
|
|
|
|
|
2023-03-24 00:34:19 +00:00
|
|
|
if (validationType == PathValidationType.AnyOs)
|
2013-08-31 20:31:58 +00:00
|
|
|
{
|
2023-03-24 00:34:19 +00:00
|
|
|
return IsPathValidForWindows(path) || IsPathValidForNonWindows(path);
|
2013-08-31 20:31:58 +00:00
|
|
|
}
|
|
|
|
|
2023-03-24 00:34:19 +00:00
|
|
|
if (OsInfo.IsNotWindows)
|
2013-08-31 20:31:58 +00:00
|
|
|
{
|
2023-03-24 00:34:19 +00:00
|
|
|
return IsPathValidForNonWindows(path);
|
2013-08-31 20:31:58 +00:00
|
|
|
}
|
|
|
|
|
2023-03-24 00:34:19 +00:00
|
|
|
return IsPathValidForWindows(path);
|
2013-08-31 20:31:58 +00:00
|
|
|
}
|
|
|
|
|
2013-05-11 05:59:42 +00:00
|
|
|
public static bool ContainsInvalidPathChars(this string text)
|
|
|
|
{
|
2023-08-04 00:55:50 +00:00
|
|
|
if (text.IsNullOrWhiteSpace())
|
|
|
|
{
|
2023-09-19 04:05:28 +00:00
|
|
|
throw new ArgumentNullException(nameof(text));
|
2023-08-04 00:55:50 +00:00
|
|
|
}
|
|
|
|
|
2013-05-11 05:59:42 +00:00
|
|
|
return text.IndexOfAny(Path.GetInvalidPathChars()) >= 0;
|
|
|
|
}
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
private static string GetProperCapitalization(DirectoryInfo dirInfo)
|
2013-04-30 00:39:54 +00:00
|
|
|
{
|
|
|
|
var parentDirInfo = dirInfo.Parent;
|
2013-07-24 06:26:10 +00:00
|
|
|
if (parentDirInfo == null)
|
|
|
|
{
|
2022-11-07 00:44:13 +00:00
|
|
|
// Drive letter
|
2013-07-24 06:26:10 +00:00
|
|
|
return dirInfo.Name.ToUpper();
|
|
|
|
}
|
2013-08-30 02:10:43 +00:00
|
|
|
|
|
|
|
var folderName = dirInfo.Name;
|
|
|
|
|
|
|
|
if (dirInfo.Exists)
|
|
|
|
{
|
|
|
|
folderName = parentDirInfo.GetDirectories(dirInfo.Name)[0].Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Path.Combine(GetProperCapitalization(parentDirInfo), folderName);
|
2013-04-30 00:39:54 +00:00
|
|
|
}
|
|
|
|
|
2013-07-24 06:26:10 +00:00
|
|
|
public static string GetActualCasing(this string path)
|
2013-04-30 00:39:54 +00:00
|
|
|
{
|
2014-12-07 20:54:07 +00:00
|
|
|
if (OsInfo.IsNotWindows || path.StartsWith("\\"))
|
2013-07-24 06:26:10 +00:00
|
|
|
{
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2013-08-30 01:26:03 +00:00
|
|
|
if (Directory.Exists(path) && (File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory)
|
2013-07-24 06:26:10 +00:00
|
|
|
{
|
|
|
|
return GetProperCapitalization(new DirectoryInfo(path));
|
|
|
|
}
|
|
|
|
|
|
|
|
var fileInfo = new FileInfo(path);
|
2013-08-30 01:26:03 +00:00
|
|
|
var dirInfo = fileInfo.Directory;
|
|
|
|
|
|
|
|
var fileName = fileInfo.Name;
|
2013-07-24 06:26:10 +00:00
|
|
|
|
2013-08-30 01:26:03 +00:00
|
|
|
if (dirInfo != null && fileInfo.Exists)
|
|
|
|
{
|
|
|
|
fileName = dirInfo.GetFiles(fileInfo.Name)[0].Name;
|
|
|
|
}
|
2013-07-24 06:26:10 +00:00
|
|
|
|
2013-08-30 01:26:03 +00:00
|
|
|
return Path.Combine(GetProperCapitalization(dirInfo), fileName);
|
2013-04-30 00:39:54 +00:00
|
|
|
}
|
|
|
|
|
2016-11-02 18:09:29 +00:00
|
|
|
public static List<string> GetAncestorFolders(this string path)
|
|
|
|
{
|
|
|
|
var directory = new DirectoryInfo(path);
|
|
|
|
var directories = new List<string>();
|
|
|
|
|
|
|
|
while (directory != null)
|
|
|
|
{
|
|
|
|
directories.Insert(0, directory.Name);
|
|
|
|
|
|
|
|
directory = directory.Parent;
|
|
|
|
}
|
|
|
|
|
|
|
|
return directories;
|
|
|
|
}
|
|
|
|
|
2018-12-07 04:24:11 +00:00
|
|
|
public static string GetAncestorPath(this string path, string ancestorName)
|
|
|
|
{
|
|
|
|
var parent = Path.GetDirectoryName(path);
|
|
|
|
|
|
|
|
while (parent != null)
|
|
|
|
{
|
|
|
|
var currentPath = parent;
|
|
|
|
parent = Path.GetDirectoryName(parent);
|
|
|
|
|
|
|
|
if (Path.GetFileName(currentPath) == ancestorName)
|
|
|
|
{
|
|
|
|
return currentPath;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-09-04 04:41:52 +00:00
|
|
|
public static string GetLongestCommonPath(this List<string> paths)
|
|
|
|
{
|
|
|
|
var firstPath = paths.First();
|
|
|
|
var length = firstPath.Length;
|
|
|
|
|
2023-05-23 10:52:39 +00:00
|
|
|
for (var i = 1; i < paths.Count; i++)
|
2021-09-04 04:41:52 +00:00
|
|
|
{
|
|
|
|
var path = paths[i];
|
|
|
|
|
|
|
|
length = Math.Min(length, path.Length);
|
|
|
|
|
2023-05-23 10:52:39 +00:00
|
|
|
for (var characterIndex = 0; characterIndex < length; characterIndex++)
|
2021-09-04 04:41:52 +00:00
|
|
|
{
|
|
|
|
if (path[characterIndex] != firstPath[characterIndex])
|
|
|
|
{
|
|
|
|
length = characterIndex;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var substring = firstPath.Substring(0, length);
|
|
|
|
var lastSeparatorIndex = substring.LastIndexOfAny(new[] { '/', '\\' });
|
|
|
|
|
|
|
|
return substring.Substring(0, lastSeparatorIndex);
|
|
|
|
}
|
|
|
|
|
2022-10-15 15:54:38 +00:00
|
|
|
public static string ProcessNameToExe(this string processName)
|
2021-07-30 04:47:53 +00:00
|
|
|
{
|
2022-10-15 15:54:38 +00:00
|
|
|
if (OsInfo.IsWindows)
|
2021-07-30 04:47:53 +00:00
|
|
|
{
|
|
|
|
processName += ".exe";
|
|
|
|
}
|
|
|
|
|
|
|
|
return processName;
|
|
|
|
}
|
|
|
|
|
2024-04-28 01:04:50 +00:00
|
|
|
public static string CleanPath(this string path)
|
|
|
|
{
|
|
|
|
return Path.Join(path.Split(Path.DirectorySeparatorChar).Select(s => s.Trim()).ToArray());
|
|
|
|
}
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetAppDataPath(this IAppFolderInfo appFolderInfo)
|
2011-11-13 07:27:16 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
return appFolderInfo.AppDataFolder;
|
2013-05-20 00:30:02 +00:00
|
|
|
}
|
|
|
|
|
2021-11-06 20:44:26 +00:00
|
|
|
public static string GetDataProtectionPath(this IAppFolderInfo appFolderInfo)
|
|
|
|
{
|
|
|
|
return Path.Combine(GetAppDataPath(appFolderInfo), "asp");
|
|
|
|
}
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetLogFolder(this IAppFolderInfo appFolderInfo)
|
2013-05-20 00:30:02 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
return Path.Combine(GetAppDataPath(appFolderInfo), "logs");
|
2011-11-13 07:27:16 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetConfigPath(this IAppFolderInfo appFolderInfo)
|
2011-11-13 07:27:16 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
return Path.Combine(GetAppDataPath(appFolderInfo), APP_CONFIG_FILE);
|
2011-11-13 07:27:16 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetMediaCoverPath(this IAppFolderInfo appFolderInfo)
|
2011-12-02 07:07:18 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
return Path.Combine(GetAppDataPath(appFolderInfo), "MediaCover");
|
2011-11-13 05:19:19 +00:00
|
|
|
}
|
2011-11-14 00:22:18 +00:00
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetUpdateLogFolder(this IAppFolderInfo appFolderInfo)
|
2011-11-21 02:13:10 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
return Path.Combine(GetAppDataPath(appFolderInfo), UPDATE_LOG_FOLDER_NAME);
|
2011-11-21 02:13:10 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetUpdateSandboxFolder(this IAppFolderInfo appFolderInfo)
|
2011-11-14 00:22:18 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
return Path.Combine(appFolderInfo.TempFolder, UPDATE_SANDBOX_FOLDER_NAME);
|
2011-11-14 00:22:18 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetUpdateBackUpFolder(this IAppFolderInfo appFolderInfo)
|
2011-11-14 00:22:18 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_BACKUP_FOLDER_NAME);
|
2011-11-14 00:22:18 +00:00
|
|
|
}
|
|
|
|
|
2014-02-07 02:13:24 +00:00
|
|
|
public static string GetUpdateBackUpAppDataFolder(this IAppFolderInfo appFolderInfo)
|
|
|
|
{
|
|
|
|
return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_BACKUP_APPDATA_FOLDER_NAME);
|
|
|
|
}
|
|
|
|
|
2014-02-08 02:16:19 +00:00
|
|
|
public static string GetUpdateBackupConfigFile(this IAppFolderInfo appFolderInfo)
|
|
|
|
{
|
|
|
|
return Path.Combine(GetUpdateBackUpAppDataFolder(appFolderInfo), APP_CONFIG_FILE);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static string GetUpdateBackupDatabase(this IAppFolderInfo appFolderInfo)
|
|
|
|
{
|
2017-09-18 03:25:28 +00:00
|
|
|
return Path.Combine(GetUpdateBackUpAppDataFolder(appFolderInfo), DB);
|
2014-02-08 02:16:19 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetUpdatePackageFolder(this IAppFolderInfo appFolderInfo)
|
2011-11-14 00:22:18 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_PACKAGE_FOLDER_NAME);
|
2011-11-14 00:22:18 +00:00
|
|
|
}
|
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetUpdateClientFolder(this IAppFolderInfo appFolderInfo)
|
2011-11-14 01:27:11 +00:00
|
|
|
{
|
2013-07-05 04:43:28 +00:00
|
|
|
return Path.Combine(GetUpdatePackageFolder(appFolderInfo), UPDATE_CLIENT_FOLDER_NAME);
|
2011-11-14 01:27:11 +00:00
|
|
|
}
|
|
|
|
|
2022-10-15 15:54:38 +00:00
|
|
|
public static string GetUpdateClientExePath(this IAppFolderInfo appFolderInfo)
|
2011-11-14 00:22:18 +00:00
|
|
|
{
|
2022-10-15 15:54:38 +00:00
|
|
|
return Path.Combine(GetUpdateSandboxFolder(appFolderInfo), UPDATE_CLIENT_EXE_NAME).ProcessNameToExe();
|
2011-11-14 00:22:18 +00:00
|
|
|
}
|
2011-11-21 02:13:10 +00:00
|
|
|
|
2018-01-13 01:52:42 +00:00
|
|
|
public static string GetDatabase(this IAppFolderInfo appFolderInfo)
|
2012-01-27 05:05:09 +00:00
|
|
|
{
|
2018-01-13 01:52:42 +00:00
|
|
|
return Path.Combine(GetAppDataPath(appFolderInfo), DB);
|
2012-01-27 05:05:09 +00:00
|
|
|
}
|
2013-01-06 08:11:14 +00:00
|
|
|
|
2018-01-13 01:52:42 +00:00
|
|
|
public static string GetDatabaseRestore(this IAppFolderInfo appFolderInfo)
|
2013-03-25 04:36:24 +00:00
|
|
|
{
|
2018-01-13 01:52:42 +00:00
|
|
|
return Path.Combine(GetAppDataPath(appFolderInfo), DB_RESTORE);
|
2013-03-25 04:36:24 +00:00
|
|
|
}
|
2013-05-21 03:20:29 +00:00
|
|
|
|
2013-07-05 04:43:28 +00:00
|
|
|
public static string GetLogDatabase(this IAppFolderInfo appFolderInfo)
|
2013-05-21 03:20:29 +00:00
|
|
|
{
|
2017-09-18 03:25:28 +00:00
|
|
|
return Path.Combine(GetAppDataPath(appFolderInfo), LOG_DB);
|
2013-05-21 03:20:29 +00:00
|
|
|
}
|
2013-07-24 15:08:31 +00:00
|
|
|
|
|
|
|
public static string GetNlogConfigPath(this IAppFolderInfo appFolderInfo)
|
|
|
|
{
|
|
|
|
return Path.Combine(appFolderInfo.StartUpFolder, NLOG_CONFIG_FILE);
|
|
|
|
}
|
2023-03-24 00:34:19 +00:00
|
|
|
|
|
|
|
private static bool IsPathValidForWindows(string path)
|
|
|
|
{
|
|
|
|
return path.StartsWith("\\") || WindowsPathWithDriveRegex.IsMatch(path);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static bool IsPathValidForNonWindows(string path)
|
|
|
|
{
|
|
|
|
return path.StartsWith("/");
|
|
|
|
}
|
2011-11-13 05:19:19 +00:00
|
|
|
}
|
2017-05-10 20:48:36 +00:00
|
|
|
}
|