refactor: IcdZip Unzip raises an exception instead of generating a message

This commit is contained in:
Chris Cameron
2018-06-06 13:45:05 -04:00
parent 1f023c14d0
commit 2602380100

View File

@@ -23,28 +23,17 @@ namespace ICD.Common.Utils.IO.Compression
/// </summary> /// </summary>
/// <param name="path"></param> /// <param name="path"></param>
/// <param name="outputPath"></param> /// <param name="outputPath"></param>
/// <param name="message"></param> public static void Unzip(string path, string outputPath)
public static bool Unzip(string path, string outputPath, out string message)
{
try
{ {
#if SIMPLSHARP #if SIMPLSHARP
CrestronZIP.ResultCode result = CrestronZIP.Unzip(path, outputPath); CrestronZIP.ResultCode result = CrestronZIP.Unzip(path, outputPath);
message = result.ToString(); if (result != CrestronZIP.ResultCode.ZR_OK)
return result == CrestronZIP.ResultCode.ZR_OK; throw new InvalidOperationException(result.ToString());
#else #else
using (ZipArchive archive = ZipFile.Open(path, ZipArchiveMode.Read)) using (ZipArchive archive = ZipFile.Open(path, ZipArchiveMode.Read))
archive.ExtractToDirectory(outputPath); archive.ExtractToDirectory(outputPath);
message = "Success";
return true;
#endif #endif
} }
catch (Exception e)
{
message = e.Message;
return false;
}
}
/// <summary> /// <summary>
/// Gets the sequence of files names in the archive at the given path. /// Gets the sequence of files names in the archive at the given path.