More prep for a better future

This commit is contained in:
Matt Nadareski
2025-09-06 18:09:54 -04:00
parent cc16770126
commit ed8e97aa0c
4 changed files with 17 additions and 8 deletions

View File

@@ -21,7 +21,7 @@ namespace NDecrypt.Core
#region Encrypt
/// <inheritdoc/>
public bool EncryptFile(string input, bool force)
public bool EncryptFile(string input, string? output, bool force)
{
try
{
@@ -67,7 +67,7 @@ namespace NDecrypt.Core
#region Decrypt
/// <inheritdoc/>
public bool DecryptFile(string input, bool force)
public bool DecryptFile(string input, string? output, bool force)
{
try
{

View File

@@ -6,17 +6,21 @@
/// Attempts to encrypt an input file
/// </summary>
/// <param name="input">Name of the file to encrypt</param>
/// <param name="output">Optional name of the file to write to</param>
/// <param name="force">Indicates if the operation should be forced</param>
/// <returns>True if the file could be encrypted, false otherwise</returns>
bool EncryptFile(string input, bool force);
/// <remarks>If an output filename is not provided, the input file will be overwritten</remarks>
bool EncryptFile(string input, string? output, bool force);
/// <summary>
/// Attempts to decrypt an input file
/// </summary>
/// <param name="input">Name of the file to decrypt</param>
/// <param name="output">Optional name of the file to write to</param>
/// <param name="force">Indicates if the operation should be forced</param>
/// <returns>True if the file could be decrypted, false otherwise</returns>
bool DecryptFile(string input, bool force);
/// <remarks>If an output filename is not provided, the input file will be overwritten</remarks>
bool DecryptFile(string input, string? output, bool force);
/// <summary>
/// Attempts to get information on an input file

View File

@@ -35,7 +35,7 @@ namespace NDecrypt.Core
#region Decrypt
/// <inheritdoc/>
public bool DecryptFile(string input, bool force)
public bool DecryptFile(string input, string? output, bool force)
{
// Ensure the constants are all set
if (_decryptArgs.IsReady != true)
@@ -448,7 +448,7 @@ namespace NDecrypt.Core
#region Encrypt
/// <inheritdoc/>
public bool EncryptFile(string input, bool force)
public bool EncryptFile(string input, string? output, bool force)
{
// Ensure the constants are all set
if (_decryptArgs.IsReady != true)

View File

@@ -67,13 +67,18 @@ namespace NDecrypt
Console.WriteLine($"Processing {path}");
// TODO: Determine how separate output files should be named
// - Consider using something like `.enc` and `.dec` appended/replaced
// - Needs a new flag to enable not overwriting
// - Maybe make overwriting an option and new file be default?
// Encrypt or decrypt the file as requested
if (feature == Feature.Encrypt && !tool.EncryptFile(path, force))
if (feature == Feature.Encrypt && !tool.EncryptFile(path, null, force))
{
Console.WriteLine("Encryption failed!");
return;
}
else if (feature == Feature.Decrypt && !tool.DecryptFile(path, force))
else if (feature == Feature.Decrypt && !tool.DecryptFile(path, null, force))
{
Console.WriteLine("Decryption failed!");
return;