Skip to content

TryOpen API #434

@AlexeiScherbakov

Description

@AlexeiScherbakov

API tries open Archive, and return IArchive + true,when file is archive, false when file is not archive.
Exceptions are not thrown. Via ArchiveTypeMask user can set needed archive types (for example exclude Tar if it is not needed).

Add TryOpen to ArchiveFactory

static bool ArchiveFactory.TryOpen(Stream stream, ReaderOptions readerOptions,ArchiveTypeMask archiveTypes, out IArchive archive);
static bool ArchiveFactory.TryOpen(string filePath, ReaderOptions options, ArchiveTypeMask archiveTypes, out IArchive archive);
static bool ArchiveFactory.TryOpen(FileInfo fileInfo, ReaderOptions options,ArchiveTypeMask archiveTypes,out IArchive archive);

Add TryOpen to ReaderFactory
static bool ReaderFactory.TryOpen(Stream stream, ReaderOptions options,ArchiveTypeMask archiveTypes, out IReader reader)

Add ArchiveTypeMask

    [Flags]
    public enum ArchiveTypeMask
    {
        None = 0,
        Rar = 1,
        Zip = 1 << 1,
        Tar = 1 << 2,
        SevenZip = 1 << 3,
        GZip = 1 << 4,
        BZip2 = 1 << 5,
        LZip = 1 << 6,

        AllExceptTar = Rar | Zip | SevenZip | GZip | BZip2 | LZip,
        All = AllExceptTar | Tar
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions