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

Magic database loading methods. More...

Collaboration diagram for Database Loading:

Functions

void Recognition::Magic::LoadDatabaseFile (const std::filesystem::path &database_file=DEFAULT_DATABASE_FILE)
 Load a magic database file.
bool Recognition::Magic::LoadDatabaseFile (const std::nothrow_t &tag, const std::filesystem::path &database_file=DEFAULT_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::LoadDatabaseFile ( const std::filesystem::path & database_file = DEFAULT_DATABASE_FILE)

Load a magic database file.

Loads the specified magic database file into the Magic instance. Must be called after Open() before file identification can be performed.

Parameters
[in]database_filePath to the database file (default: DEFAULT_DATABASE_FILE).
Exceptions
MagicIsClosedIf the Magic instance is closed.
EmptyPathIf database_file path is empty.
PathDoesNotExistIf database_file does not exist.
PathIsNotRegularFileIf database_file is not a regular file.
MagicLoadDatabaseFileErrorIf loading fails.
Magic magic;
magic.LoadDatabaseFile(); // Load default database
// Or load custom database
magic.LoadDatabaseFile("/custom/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
void Open(FlagsMaskT flags_mask)
Open Magic with specified flags.
Definition magic.cpp:2651
Note
The ".mgc" extension is automatically appended if appropriate.
See also
Open()
IsDatabaseLoaded()
Since
10.0.0
Examples
magic_examples.cpp.

◆ LoadDatabaseFile() [2/2]

bool Recognition::Magic::LoadDatabaseFile ( const std::nothrow_t & tag,
const std::filesystem::path & database_file = DEFAULT_DATABASE_FILE )
nodiscardnoexcept

Load a magic database file (noexcept version).

Parameters
[in]tagPass std::nothrow to select this overload.
[in]database_filePath to the database file (default: DEFAULT_DATABASE_FILE).
Returns
true on success, false on failure.
Note
The ".mgc" extension is automatically appended if appropriate.
Since
10.0.0