diff --git a/WPinternals/CommandLine.cs b/WPinternals/CommandLine.cs index 39992ba..7d1ddf9 100644 --- a/WPinternals/CommandLine.cs +++ b/WPinternals/CommandLine.cs @@ -223,7 +223,11 @@ namespace WPinternals UIContext.Send(s => Notifier.Start(), null); FlashModel = (NokiaFlashModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash); GPT GPT = FlashModel.ReadGPT(); // May throw NotSupportedException - Directory.CreateDirectory(Path.GetDirectoryName(args[2])); + string DirPath = Path.GetDirectoryName(args[2]); + if (!string.IsNullOrEmpty(DirPath) && !Directory.Exists(DirPath)) + { + Directory.CreateDirectory(DirPath); + } GPT.WritePartitions(args[2]); FlashModel.SwitchToFlashAppContext(); Notifier.Stop(); @@ -237,6 +241,35 @@ namespace WPinternals LogFile.EndAction("BackupGPT"); } break; + case "convertgpt": + if (args.Length < 4) + { + throw new ArgumentException("Wrong number of arguments. Usage: WPinternals.exe -ConvertGPT "); + } + + LogFile.BeginAction("ConvertGPT"); + try + { + using var stream = File.OpenRead(args[2]); + byte[] GPTBuffer = new byte[34 * 0x200]; + stream.Read(GPTBuffer, 0, 34 * 0x200); + GPT GPT = new(GPTBuffer);// May throw NotSupportedException + string DirPath = Path.GetDirectoryName(args[3]); + if (!string.IsNullOrEmpty(DirPath) && !Directory.Exists(DirPath)) + { + Directory.CreateDirectory(DirPath); + } + GPT.WritePartitions(args[3]); + } + catch (Exception Ex) + { + LogFile.LogException(Ex); + } + finally + { + LogFile.EndAction("ConvertGPT"); + } + break; case "restoregpt": if (args.Length < 3) { @@ -393,7 +426,11 @@ namespace WPinternals }; } string EfiPath = Path.Combine(args[3], Name); - Directory.CreateDirectory(Path.GetDirectoryName(EfiPath)); + string DirPath = Path.GetDirectoryName(EfiPath); + if (!string.IsNullOrEmpty(DirPath) && !Directory.Exists(DirPath)) + { + Directory.CreateDirectory(DirPath); + } File.WriteAllBytes(EfiPath, EfiBinary); } break; @@ -1968,6 +2005,7 @@ namespace WPinternals LogFile.Log("WPinternals -ClearNV", LogType.ConsoleOnly); LogFile.Log("WPinternals -ReadGPT", LogType.ConsoleOnly); LogFile.Log("WPinternals -BackupGPT ", LogType.ConsoleOnly); + LogFile.Log("WPinternals -ConvertGPT ", LogType.ConsoleOnly); LogFile.Log("WPinternals -RestoreGPT ", LogType.ConsoleOnly); LogFile.Log("WPinternals -MergeGPT ", LogType.ConsoleOnly); LogFile.Log(" ", LogType.ConsoleOnly); diff --git a/WPinternals/Models/GPT.cs b/WPinternals/Models/GPT.cs index 2a2e622..81c83bd 100644 --- a/WPinternals/Models/GPT.cs +++ b/WPinternals/Models/GPT.cs @@ -545,7 +545,7 @@ namespace WPinternals internal void WritePartitions(string Path) { string DirPath = System.IO.Path.GetDirectoryName(Path); - if (!Directory.Exists(DirPath)) + if (!string.IsNullOrEmpty(DirPath) && !Directory.Exists(DirPath)) { Directory.CreateDirectory(DirPath); } diff --git a/WPinternals/WPinternals.csproj b/WPinternals/WPinternals.csproj index 3a59f30..788e81d 100644 --- a/WPinternals/WPinternals.csproj +++ b/WPinternals/WPinternals.csproj @@ -29,8 +29,6 @@ true - true - Heathcliff74.snk 1701;1702;CA1416;RCS1090;RCS1163 @@ -302,14 +300,10 @@ x64 MinimumRecommendedRules.ruleset - - Heathcliff74.snk - Designer - @@ -321,23 +315,6 @@ - - - False - Microsoft .NET Framework 4.5 %28x86 and x64%29 - true - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - -