80 std::filesystem::path,
224 const std::nothrow_t& tag,
258 const std::nothrow_t& tag,
303 [[nodiscard]] operator
bool() const noexcept;
313 [[nodiscard]] static
bool check(
323 void close() noexcept;
336 [[nodiscard]] static
bool compile(
357 const std::nothrow_t& tag
381 const std::nothrow_t& tag
401 const std::nothrow_t& tag
409 [[nodiscard]] static std::
string get_version() noexcept;
425 const std::filesystem::path& path
437 const std::filesystem::path& path,
438 const std::nothrow_t& tag
458 const std::filesystem::path& directory,
459 std::filesystem::directory_options option = std::filesystem::
460 directory_options::follow_directory_symlink
485 const std::filesystem::path& directory,
487 std::filesystem::directory_options option = std::filesystem::
488 directory_options::follow_directory_symlink
504 const std::filesystem::path& directory,
505 const std::nothrow_t& tag,
506 std::filesystem::directory_options option = std::filesystem::
507 directory_options::follow_directory_symlink
524 const std::filesystem::path& directory,
525 const std::nothrow_t& tag,
527 std::filesystem::directory_options option = std::filesystem::
528 directory_options::follow_directory_symlink
552 {std::ranges::begin(files), std::ranges::end(files)}
577 {std::ranges::begin(files), std::ranges::end(files)},
592 const std::nothrow_t& tag
596 {std::ranges::begin(files), std::ranges::end(files)},
612 const std::nothrow_t& tag,
617 {std::ranges::begin(files), std::ranges::end(files)},
635 [[nodiscard]]
bool is_open() const noexcept;
645 [[nodiscard]]
bool is_valid() const noexcept;
675 const std::nothrow_t& tag,
702 [[nodiscard]]
bool open(
704 const std::nothrow_t& tag
730 [[nodiscard]]
bool open(
732 const std::nothrow_t& tag
755 const std::nothrow_t& tag
778 const std::nothrow_t& tag
804 const std::nothrow_t& tag
827 const std::nothrow_t& tag
837 const std::filesystem::path& directory,
838 std::filesystem::directory_options option,
843 const std::filesystem::path& directory,
844 const std::nothrow_t& tag,
845 std::filesystem::directory_options option,
856 const std::nothrow_t& tag,
874 const std::
string& type_separator =
" -> "
888 const std::
string& type_separator =
" -> ",
889 const std::
string& file_separator =
"\n"
913 const std::
string& type_separator =
" -> "
927 const std::
string& type_separator =
" -> ",
928 const std::
string& file_separator =
"\n"
950 const std::
string& separator =
", "
972 const std::
string& value_separator =
": "
986 const std::
string& value_separator =
": ",
987 const std::
string& parameter_separator =
", "
bool is_open() const noexcept
Used for testing whether magic is open or closed.
Definition magic.cpp:1155
void set_flags(flags_mask_t flags_mask)
Set the flags of magic.
Definition magic.cpp:1201
expected_types_of_files_t identify_files(const std::filesystem::path &directory, const std::nothrow_t &tag, tracker_t tracker, std::filesystem::directory_options option=std::filesystem::directory_options::follow_directory_symlink) const noexcept
Identify the types of all files in a directory with progress tracking, noexcept version.
Definition magic.hpp:523
void set_parameters(const parameter_value_map_t ¶meters)
Set the values of the parameters of magic.
Definition magic.cpp:1241
std::size_t get_parameter(parameters parameter) const
Get the value of a parameter of magic.
Definition magic.cpp:1027
static bool check(const std::filesystem::path &database_file=default_database_file) noexcept
Check the validity of entries in the colon separated database files passed in as database_file.
Definition magic.cpp:996
std::unique_ptr< magic_private > m_impl
Definition magic.hpp:832
std::string error_message_t
String type representing an error message from file identification.
Definition magic.hpp:51
flags_container_t get_flags() const
Get the flags of magic.
Definition magic.cpp:1015
utility::shared_progress_tracker_t tracker_t
Alias for a shared pointer to a progress tracker used for monitoring file identification progress.
Definition magic.hpp:98
bool is_database_loaded() const noexcept
Used for testing whether a magic database is loaded or not.
Definition magic.cpp:1150
flags
The flags enums are used for configuring the flags of a magic.
Definition magic.hpp:105
@ raw
Definition magic.hpp:116
@ no_check_tokens
Definition magic.hpp:133
@ no_check_cdf
Definition magic.hpp:131
@ symlink
Definition magic.hpp:109
@ no_check_apptype
Definition magic.hpp:128
@ error
Definition magic.hpp:117
@ no_check_compress
Definition magic.hpp:125
@ no_check_tar
Definition magic.hpp:126
@ mime_type
Definition magic.hpp:112
@ mime_encoding
Definition magic.hpp:118
@ debug
Definition magic.hpp:108
@ no_check_elf
Definition magic.hpp:129
@ none
Definition magic.hpp:107
@ nodesc
Definition magic.hpp:124
@ compress_transp
Definition magic.hpp:122
@ apple
Definition magic.hpp:120
@ mime
Definition magic.hpp:119
@ compress
Definition magic.hpp:110
@ no_check_text
Definition magic.hpp:130
@ no_check_soft
Definition magic.hpp:127
@ no_compress_fork
Definition magic.hpp:123
@ preserve_atime
Definition magic.hpp:115
@ no_check_builtin
Definition magic.hpp:137
@ extension
Definition magic.hpp:121
@ devices
Definition magic.hpp:111
@ no_check_encoding
Definition magic.hpp:134
@ no_check_simh
Definition magic.hpp:136
@ no_check_csv
Definition magic.hpp:132
@ continue_search
Definition magic.hpp:113
@ check_database
Definition magic.hpp:114
@ no_check_json
Definition magic.hpp:135
magic() noexcept
Construct magic without opening it.
Definition magic.cpp:945
expected_types_of_files_t::value_type expected_type_of_a_file_t
Key-value pair representing a single file and its expected file type result.
Definition magic.hpp:89
void open(flags_mask_t flags_mask)
Open magic using the flags.
Definition magic.cpp:1178
std::bitset< 30uz > flags_mask_t
Bitmask type representing a set of magic::flags used to configure the magic instance.
Definition magic.hpp:37
std::vector< flags > flags_container_t
Container type holding a collection of magic::flags.
Definition magic.hpp:165
std::vector< std::filesystem::path > default_file_container_t
Definition magic.hpp:834
file_type_t identify_file(const std::filesystem::path &path) const
Identify the type of a file.
Definition magic.cpp:1057
parameters
The parameters enums are used for displaying or modifying the parameters of a magic.
Definition magic.hpp:145
@ bytes_max
Definition magic.hpp:153
@ indir_max
Definition magic.hpp:147
@ elf_shsize_max
Definition magic.hpp:155
@ regex_max
Definition magic.hpp:152
@ elf_phnum_max
Definition magic.hpp:149
@ name_max
Definition magic.hpp:148
@ elf_shnum_max
Definition magic.hpp:150
@ mag_warn_max
Definition magic.hpp:156
@ elf_notes_max
Definition magic.hpp:151
@ encoding_max
Definition magic.hpp:154
parameter_value_map_t::value_type parameter_value_t
Key-value pair representing a single parameter and its value.
Definition magic.hpp:179
expected_types_of_files_t identify_files(const utility::file_container auto &files, const std::nothrow_t &tag, tracker_t tracker) const noexcept
Identify the types of files with progress tracking, noexcept version.
Definition magic.hpp:610
types_of_files_t identify_files(const std::filesystem::path &directory, tracker_t tracker, std::filesystem::directory_options option=std::filesystem::directory_options::follow_directory_symlink) const
Identify the types of all files in a directory with progress tracking.
Definition magic.hpp:484
types_of_files_t::value_type type_of_a_file_t
Key-value pair representing a single file and its detected type.
Definition magic.hpp:72
void set_parameter(parameters parameter, std::size_t value)
Set the value of a parameter of magic.
Definition magic.cpp:1227
bool is_valid() const noexcept
Used for testing whether magic is valid for identifying file types or not.
Definition magic.cpp:1160
static std::string_view default_database_file
The path of the default database file.
Definition magic.hpp:184
std::map< parameters, std::size_t > parameter_value_map_t
Map from magic::parameters to their corresponding values.
Definition magic.hpp:172
std::expected< file_type_t, error_message_t > expected_file_type_t
Result type for file identification, containing either a file type or an error message.
Definition magic.hpp:58
types_of_files_t identify_directory_impl(const std::filesystem::path &directory, std::filesystem::directory_options option, tracker_t tracker=utility::make_shared_progress_tracker()) const
Definition magic.cpp:1077
std::string file_type_t
String type representing the detected type of a file.
Definition magic.hpp:44
expected_types_of_files_t identify_files(const utility::file_container auto &files, const std::nothrow_t &tag) const noexcept
Identify the types of files, noexcept version.
Definition magic.hpp:590
expected_types_of_files_t identify_files(const std::filesystem::path &directory, const std::nothrow_t &tag, 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:503
std::map< std::filesystem::path, file_type_t > types_of_files_t
Map from file paths to their detected types.
Definition magic.hpp:65
void close() noexcept
Close magic.
Definition magic.cpp:1003
friend std::string to_string(flags)
Convert the magic::flags to string.
Definition magic.cpp:889
void load_database_file(const std::filesystem::path &database_file=default_database_file)
Load a magic database file.
Definition magic.cpp:1165
types_of_files_t identify_container_impl(const default_file_container_t &files, tracker_t tracker=utility::make_shared_progress_tracker()) const
Definition magic.cpp:1119
types_of_files_t identify_files(const utility::file_container auto &files, tracker_t tracker) const
Identify the types of files with progress tracking.
Definition magic.hpp:571
std::map< std::filesystem::path, expected_file_type_t > expected_types_of_files_t
Map from file paths to expected file type results (success or error).
Definition magic.hpp:79
parameter_value_map_t get_parameters() const
Get the values of all parameters of magic.
Definition magic.cpp:1040
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:457
static std::string get_version() noexcept
Get the version of the Magic Number Recognition Library.
Definition magic.cpp:1052
static bool compile(const std::filesystem::path &database_file=default_database_file) noexcept
Compile the colon separated list of database files passed in as database_file.
Definition magic.cpp:1008
types_of_files_t identify_files(const utility::file_container auto &files) const
Identify the types of files.
Definition magic.hpp:547
The file_container concept specifies the requirements of a container which can be used as a file cont...
Definition utility.hpp:82
Definition percentage.hpp:12
std::shared_ptr< progress_tracker > shared_progress_tracker_t
Alias for a shared pointer to progress_tracker.
Definition progress_tracker.hpp:179