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

Instance lifecycle management. More...

Collaboration diagram for Instance Control:

Functions

bool Recognition::Magic::MagicPrivate::Compile (const std::filesystem::path &database_file) const noexcept
 Compile a magic database from source.

Detailed Description

Instance lifecycle management.

Methods for compiling databases and controlling instance state.

Function Documentation

◆ Compile()

bool Recognition::Magic::MagicPrivate::Compile ( const std::filesystem::path & database_file) const
inlinenodiscardnoexcept

Compile a magic database from source.

Compiles magic source files into binary format by calling magic_compile() from libmagic. The compiled output file is named by appending ".mgc" to the source filename.

Parameters
[in]database_filePath to the database source file.
Returns
true on successful compilation, false if:
  • Instance is not open
  • database_file is empty
  • Compilation fails
Preconditions
  • Instance must be in Opened or Valid state
  • database_file must be non-empty
Output File
If database_file is "/path/to/magic", the compiled output will be "/path/to/magic.mgc".
libmagic Call
Detail::magic_compile(m_cookie.get(), database_file.string().c_str());
CookieT m_cookie
Definition magic.cpp:1920
See also
Magic::Compile()
Check()