Cleanup and tests fixup
This commit is contained in:
parent
154b30c3fd
commit
6ebf5d6254
6 changed files with 88 additions and 188 deletions
|
@ -1,42 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using SharpCompress.Archives;
|
||||
|
||||
namespace API.Archive
|
||||
{
|
||||
public static class Archive
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if a File can be opened. Requires up to 2 opens of the filestream.
|
||||
/// </summary>
|
||||
/// <param name="archivePath"></param>
|
||||
/// <returns></returns>
|
||||
public static ArchiveLibrary CanOpen(string archivePath)
|
||||
{
|
||||
// TODO: Should I introduce something for NotFound?
|
||||
if (!File.Exists(archivePath) || !Parser.Parser.IsArchive(archivePath)) return ArchiveLibrary.NotSupported;
|
||||
|
||||
try
|
||||
{
|
||||
using var a2 = ZipFile.OpenRead(archivePath);
|
||||
return ArchiveLibrary.Default;
|
||||
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
using var a1 = ArchiveFactory.Open(archivePath);
|
||||
return ArchiveLibrary.SharpCompress;
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return ArchiveLibrary.NotSupported;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
namespace API.Archive
|
||||
{
|
||||
public class ArchiveMetadata
|
||||
{
|
||||
public byte[] CoverImage { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public int Pages { get; set; }
|
||||
//public string Format { get; set; }
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue