Libmagicxx v10.0.3
A modern C++23 wrapper for libmagic — the library that powers the Unix file command.
Loading...
Searching...
No Matches
Open Reopen

Instance initialization methods. More...

Collaboration diagram for Open Reopen:

Functions

void Recognition::Magic::Open (FlagsMaskT flags_mask)
 Open Magic with specified flags.
bool Recognition::Magic::Open (FlagsMaskT flags_mask, const std::nothrow_t &tag) noexcept
 Open Magic with specified flags (noexcept version).
void Recognition::Magic::Open (const FlagsContainerT &flags_container)
 Open Magic with a container of flags.
bool Recognition::Magic::Open (const FlagsContainerT &flags_container, const std::nothrow_t &tag) noexcept
 Open Magic with a container of flags (noexcept version).

Detailed Description

Instance initialization methods.

Methods for opening and reopening the Magic instance.

Function Documentation

◆ Open() [1/4]

void Recognition::Magic::Open ( const FlagsContainerT & flags_container)

Open Magic with a container of flags.

Parameters
[in]flags_containerContainer of Flags values.
Exceptions
MagicOpenErrorIf opening fails.
Since
10.0.0

◆ Open() [2/4]

bool Recognition::Magic::Open ( const FlagsContainerT & flags_container,
const std::nothrow_t & tag )
nodiscardnoexcept

Open Magic with a container of flags (noexcept version).

Parameters
[in]flags_containerContainer of Flags values.
[in]tagPass std::nothrow to select this overload.
Returns
true on success, false on failure.
Since
10.0.0

◆ Open() [3/4]

void Recognition::Magic::Open ( FlagsMaskT flags_mask)

Open Magic with specified flags.

Opens (or reopens) the Magic instance with the specified configuration flags. If already open, the instance is closed first then reopened.

Lifecycle Transition
  • From ClosedOpened
  • From OpenedOpened (reopens with new flags)
  • From ValidOpened (database unloaded, must reload)
Parameters
[in]flags_maskConfiguration flags (use Flags enum values combined with |).
Exceptions
MagicOpenErrorIf opening fails.
Magic magic;
Magic() noexcept
Default constructor. Creates an unopened Magic instance.
Definition magic.cpp:2421
void LoadDatabaseFile(const std::filesystem::path &database_file=DEFAULT_DATABASE_FILE)
Load a magic database file.
Definition magic.cpp:2638
@ Mime
Definition magic.hpp:328
@ Compress
Definition magic.hpp:319
void Open(FlagsMaskT flags_mask)
Open Magic with specified flags.
Definition magic.cpp:2651
Note
A database must be loaded after opening before identification works.
Warning
Calling Open() on a Valid instance unloads the database. You must call LoadDatabaseFile() again.
See also
Magic Core "Magic Lifecycle" for state diagram
Close()
LoadDatabaseFile()
Since
10.0.0
Examples
magic_examples.cpp.

◆ Open() [4/4]

bool Recognition::Magic::Open ( FlagsMaskT flags_mask,
const std::nothrow_t & tag )
nodiscardnoexcept

Open Magic with specified flags (noexcept version).

Parameters
[in]flags_maskConfiguration flags.
[in]tagPass std::nothrow to select this overload.
Returns
true on success, false on failure.
Since
10.0.0