64 enum flags :
unsigned long long {
197 operator
bool() const noexcept;
214 void close() noexcept;
292 identify_file(const std::filesystem::path& path, std::nothrow_t) const noexcept;
308 const std::filesystem::path& directory,
309 std::filesystem::directory_options option = std::filesystem::directory_options::follow_directory_symlink
313 std::filesystem::recursive_directory_iterator{directory, option}
327 const std::filesystem::path& directory, std::nothrow_t,
328 std::filesystem::directory_options option = std::filesystem::directory_options::follow_directory_symlink
332 std::filesystem::recursive_directory_iterator{directory, option}, std::nothrow
461 std::ranges::for_each(files,
462 [&](
const std::filesystem::path& file){
466 return types_of_files;
473 std::ranges::for_each(files,
474 [&](
const std::filesystem::path& file){
475 expected_types_of_files[file] =
identify_file(file, std::nothrow);
478 return expected_types_of_files;
497 const std::string& type_separator =
" -> ",
498 const std::string& file_separator =
"\n"
523 const std::string& type_separator =
" -> ",
524 const std::string& file_separator =
"\n"
570 const std::string& value_separator =
": ",
571 const std::string& parameter_separator =
", "
The magic class provides a C++ wrapper over the Magic Number Recognition Library. The magic class is ...
Definition magic.hpp:26
bool is_open() const noexcept
Used for testing whether magic is open or closed.
Definition magic.cpp:537
void set_flags(flags_mask_t flags_mask)
Set the flags of magic.
Definition magic.cpp:557
static constexpr auto default_database_file
The path of the default database file.
Definition magic.hpp:127
bool compile(const std::filesystem::path &database_file=default_database_file) const noexcept
Compile the colon separated list of database files passed in as database_file.
Definition magic.cpp:494
void set_parameters(const parameter_value_map_t ¶meters)
Set the values of the parameters of magic.
Definition magic.cpp:572
std::size_t get_parameter(parameters parameter) const
Get the value of a parameter of magic.
Definition magic.cpp:506
std::unique_ptr< magic_private > m_impl
Definition magic.hpp:455
std::string error_message_t
The error_message_t typedef.
Definition magic.hpp:42
flags_container_t get_flags() const
Get the flags of magic.
Definition magic.cpp:500
flags
The flags enums are used for configuring the flags of a magic.
Definition magic.hpp:64
@ raw
Definition magic.hpp:74
@ no_check_tokens
Definition magic.hpp:91
@ no_check_cdf
Definition magic.hpp:89
@ symlink
Definition magic.hpp:67
@ no_check_apptype
Definition magic.hpp:86
@ error
Definition magic.hpp:75
@ no_check_compress
Definition magic.hpp:83
@ no_check_tar
Definition magic.hpp:84
@ mime_type
Definition magic.hpp:70
@ mime_encoding
Definition magic.hpp:76
@ debug
Definition magic.hpp:66
@ no_check_elf
Definition magic.hpp:87
@ none
Definition magic.hpp:65
@ nodesc
Definition magic.hpp:82
@ compress_transp
Definition magic.hpp:80
@ apple
Definition magic.hpp:78
@ mime
Definition magic.hpp:77
@ compress
Definition magic.hpp:68
@ no_check_text
Definition magic.hpp:88
@ no_check_soft
Definition magic.hpp:85
@ no_compress_fork
Definition magic.hpp:81
@ preserve_atime
Definition magic.hpp:73
@ no_check_builtin
Definition magic.hpp:95
@ extension
Definition magic.hpp:79
@ devices
Definition magic.hpp:69
@ no_check_encoding
Definition magic.hpp:92
@ no_check_simh
Definition magic.hpp:94
@ no_check_csv
Definition magic.hpp:90
@ continue_search
Definition magic.hpp:71
@ check_database
Definition magic.hpp:72
@ no_check_json
Definition magic.hpp:93
magic() noexcept
Construct magic without opening it.
Definition magic.cpp:454
friend std::string to_string(flags)
Convert the magic::flags to string.
Definition magic.cpp:413
void open(flags_mask_t flags_mask)
Open magic using the flags.
Definition magic.cpp:547
bool check(const std::filesystem::path &database_file=default_database_file) const noexcept
check the validity of entries in the colon separated database files passed in as database_file.
Definition magic.cpp:484
std::bitset< 30uz > flags_mask_t
The flags_mask_t typedef.
Definition magic.hpp:32
std::vector< flags > flags_container_t
The flags_container_t typedef.
Definition magic.hpp:117
file_type_t identify_file(const std::filesystem::path &path) const
Identify the type of a file.
Definition magic.cpp:524
parameters
The parameters enums are used for displaying or modifying the parameters of a magic.
Definition magic.hpp:102
expected_types_of_files_t identify_files(const std::filesystem::path &directory, std::nothrow_t, std::filesystem::directory_options option=std::filesystem::directory_options::follow_directory_symlink) const noexcept
Identify the types of all files in a directory, noexcept version.
Definition magic.hpp:326
void set_parameter(parameters parameter, std::size_t value)
Set the value of a parameter of magic.
Definition magic.cpp:567
types_of_files_t identify_files(const file_concepts::file_container auto &files) const
Identify the types of files.
Definition magic.hpp:348
std::map< parameters, std::size_t > parameter_value_map_t
The parameter_value_map_t typedef.
Definition magic.hpp:122
std::expected< file_type_t, error_message_t > expected_file_type_t
The expected_file_type_t typedef.
Definition magic.hpp:47
std::string file_type_t
The file_type_t typedef.
Definition magic.hpp:37
std::map< std::filesystem::path, file_type_t > types_of_files_t
The types_of_files_t typedef.
Definition magic.hpp:52
void close() noexcept
Close magic.
Definition magic.cpp:489
void load_database_file(const std::filesystem::path &database_file=default_database_file)
Load a magic database file.
Definition magic.cpp:542
parameter_value_map_t get_parameters() const
Get the values of all parameters of magic.
Definition magic.cpp:512
expected_types_of_files_t identify_files_impl(const std::ranges::range auto &files, std::nothrow_t) const noexcept
Definition magic.hpp:470
types_of_files_t identify_files_impl(const std::ranges::range auto &files) const
Definition magic.hpp:458
types_of_files_t identify_files(const std::filesystem::path &directory, std::filesystem::directory_options option=std::filesystem::directory_options::follow_directory_symlink) const
Identify the types of all files in a directory.
Definition magic.hpp:307
static std::string get_version() noexcept
Get the version of the Magic Number Recognition Library.
Definition magic.cpp:518
std::map< std::filesystem::path, expected_file_type_t > expected_types_of_files_t
The expected_types_of_files_t typedef.
Definition magic.hpp:57
expected_types_of_files_t identify_files(const file_concepts::file_container auto &files, std::nothrow_t) const noexcept
Identify the types of files, noexcept version.
Definition magic.hpp:361
The file_container concept specifies the requirements of a container which can be used as a file cont...
Definition file_concepts.hpp:18
std::string to_string(const magic::types_of_files_t &types_of_files, const std::string &type_separator=" -> ", const std::string &file_separator="\n")
Convert the magic::types_of_files_t to string.
Definition magic.cpp:382