| 5 | namespace PenguLoader.Main |
| 6 | { |
| 7 | internal static class Utils |
| 8 | { |
| 9 | public static void OpenFolder(string path) => Process.Start("explorer.exe", $"\"{path}\""); |
| 10 | |
| 11 | public static void OpenLink(string url) => Process.Start(new ProcessStartInfo(url) { UseShellExecute = true }); |
| 12 | |
| 13 | public static bool IsFileInUse(string path) |
| 14 | { |
| 15 | if (!File.Exists(path)) return false; |
| 16 | |
| 17 | try |
| 18 | { |
| 19 | using (new FileStream(path, FileMode.Open, FileAccess.ReadWrite, FileShare.None)) { } |
| 20 | } |
| 21 | catch |
| 22 | { |
| 23 | return true; |
| 24 | } |
| 25 | |
| 26 | return false; |
| 27 | } |
| 28 | |
| 29 | public static void DeletePath(string path, bool isDir = false) |
| 30 | { |
| 31 | try |
| 32 | { |
| 33 | if (isDir) Directory.Delete(path, true); |
| 34 | else File.Delete(path); |
| 35 | } |
| 36 | catch { } |
| 37 | } |
| 38 | |
| 39 | public static void EnsureDirectoryExists(string path) |
| 40 | { |
| 41 | if (!Directory.Exists(path)) |
| 42 | Directory.CreateDirectory(path); |
| 43 | } |
| 44 | |
| 45 | public static void EnsureFileExists(string path) |
| 46 | { |
| 47 | if (!File.Exists(path)) |
| 48 | File.Create(path).Close(); |
| 49 | } |
| 50 | |
| 51 | public static string NormalizePath(string path) |
| 52 | { |
| 53 | return Path.GetFullPath(new Uri(path).LocalPath) |
| 54 | .TrimEnd(Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar) |
| 55 | .ToUpperInvariant(); |
| 56 | } |
| 57 | } |
| 58 | } |
nothing calls this directly
no outgoing calls
no test coverage detected