[IArchive] Add base implementations.

This commit is contained in:
2023-10-06 13:29:38 +01:00
parent 42a4538e06
commit 2a4f825f51

View File

@@ -84,7 +84,7 @@ public interface IArchive
/// <summary>Identifies if the specified path contains data recognizable by this archive instance</summary>
/// <param name="path">Path.</param>
bool Identify(string path);
bool Identify(string path) => File.Exists(path) && Identify(new FileStream(path, FileMode.Open, FileAccess.Read));
/// <summary>Identifies if the specified stream contains data recognizable by this archive instance</summary>
/// <param name="stream">Stream.</param>
@@ -92,11 +92,13 @@ public interface IArchive
/// <summary>Identifies if the specified buffer contains data recognizable by this archive instance</summary>
/// <param name="buffer">Buffer.</param>
bool Identify(byte[] buffer);
bool Identify(byte[] buffer) => Identify(new MemoryStream(buffer));
/// <summary>Opens the specified path with this archive instance</summary>
/// <param name="path">Path.</param>
ErrorNumber Open(string path);
ErrorNumber Open(string path) => !File.Exists(path)
? ErrorNumber.NoSuchFile
: Open(new FileStream(path, FileMode.Open, FileAccess.Read));
/// <summary>Opens the specified stream with this archive instance</summary>
/// <param name="stream">Stream.</param>
@@ -104,7 +106,7 @@ public interface IArchive
/// <summary>Opens the specified buffer with this archive instance</summary>
/// <param name="buffer">Buffer.</param>
ErrorNumber Open(byte[] buffer);
ErrorNumber Open(byte[] buffer) => Open(new MemoryStream(buffer));
/// <summary>
/// Returns true if the archive has a file/stream/buffer currently opened and no