Skip to content

Commit

Permalink
[cli] improve output file about cmd memory (#64)
Browse files Browse the repository at this point in the history
Signed-off-by: catcherwong <[email protected]>
  • Loading branch information
catcherwong authored Aug 12, 2024
1 parent b9dd44c commit 1b1f7b0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/RDBCli/Commands/MemoryCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,20 @@ private string WriteFile(MemoryAnslysisResult dict, string output, string type)
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"res.{type}");

// the output contains file name with specific type
if (!string.IsNullOrWhiteSpace(output))
{
if (!Directory.Exists(output)) Directory.CreateDirectory(output);
path = Path.Combine(output, $"res.{type}");
if (output.EndsWith(type, StringComparison.OrdinalIgnoreCase))
{
var dir = Path.GetDirectoryName(output);
if (!Directory.Exists(dir)) Directory.CreateDirectory(dir);
path = output;
}
else
{
if (!Directory.Exists(output)) Directory.CreateDirectory(output);
path = Path.Combine(output, $"res.{type}");
}
}

byte[] bytes = null;
Expand Down

0 comments on commit 1b1f7b0

Please sign in to comment.