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

Magic database loading methods. More...

Collaboration diagram for Database Loading:

Functions

void Recognition::Magic::MagicPrivate::LoadDatabaseFile (const std::filesystem::path &database_file)
 Load a magic database file (throwing version).
bool Recognition::Magic::MagicPrivate::LoadDatabaseFile (const std::nothrow_t &tag, const std::filesystem::path &database_file) noexcept
 Load a magic database file (noexcept version).

Detailed Description

Magic database loading methods.

Methods for loading magic database files to enable identification.

Function Documentation

◆ LoadDatabaseFile() [1/2]

void Recognition::Magic::MagicPrivate::LoadDatabaseFile ( const std::filesystem::path & database_file)
inline

Load a magic database file (throwing version).

Loads the specified magic database file into this instance. On success, transitions from Opened to Valid state.

Parameters
[in]database_filePath to the magic database file.
Exceptions
MagicIsClosedIf instance is not open.
EmptyPathIf database_file is empty.
PathDoesNotExistIf database_file does not exist.
PathIsNotRegularFileIf database_file is not a regular file.
MagicLoadDatabaseFileErrorIf magic_load() fails.
Lifecycle Transition
OpenedValid
libmagic Call
Detail::magic_load(m_cookie.get(), database_file.c_str());
CookieT m_cookie
Definition magic.cpp:1920
Note
Automatically appends ".mgc" extension if needed.
Sets m_is_database_loaded = true only on success.
See also
Magic::LoadDatabaseFile()
Open()
IsValid()

◆ LoadDatabaseFile() [2/2]

bool Recognition::Magic::MagicPrivate::LoadDatabaseFile ( const std::nothrow_t & tag,
const std::filesystem::path & database_file )
inlinenodiscardnoexcept

Load a magic database file (noexcept version).

Non-throwing variant that returns success/failure status. On success, transitions from Opened to Valid state.

Parameters
[in]tagPass std::nothrow to select this overload.
[in]database_filePath to the magic database file.
Returns
true on success (now in Valid state), false on any failure (state unchanged).
Lifecycle Transition
OpenedValid on success
Failure Conditions
Returns false if:
  • Instance is not open
  • database_file is empty
  • database_file does not exist
  • database_file is not a regular file
  • magic_load() returns error
See also
Magic::LoadDatabaseFile(const std::nothrow_t&, const std::filesystem::path&)
Open()