Instance initialization methods.
More...
Instance initialization methods.
Methods for opening and reopening the Magic instance.
◆ Open() [1/4]
Open Magic with a container of flags.
- Parameters
-
| [in] | flags_container | Container of Flags values. |
- Exceptions
-
| MagicOpenError | If 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_container | Container of Flags values. |
| [in] | tag | Pass 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 Closed → Opened
- From Opened → Opened (reopens with new flags)
- From Valid → Opened (database unloaded, must reload)
- Parameters
-
| [in] | flags_mask | Configuration flags (use Flags enum values combined with |). |
- Exceptions
-
| MagicOpenError | If opening fails. |
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_mask | Configuration flags. |
| [in] | tag | Pass std::nothrow to select this overload. |
- Returns
- true on success, false on failure.
- Since
- 10.0.0