266 std::filesystem::path,
527 const std::nothrow_t& tag,
580 const std::nothrow_t& tag,
688 [[nodiscard]] operator
bool() const noexcept;
712 [[nodiscard]] static
bool Check(
750 void Close() noexcept;
775 [[nodiscard]] static
bool Compile(
822 const std::nothrow_t& tag
872 const std::nothrow_t& tag
908 const std::nothrow_t& tag
938 [[nodiscard]] static std::
string GetVersion() noexcept;
979 const std::filesystem::path& path
1004 const std::filesystem::path& path,
1005 const std::nothrow_t& tag
1038 const std::filesystem::path& directory,
1039 std::filesystem::directory_options option = std::filesystem::
1040 directory_options::follow_directory_symlink
1083 const std::filesystem::path& directory,
1085 std::filesystem::directory_options option = std::filesystem::
1086 directory_options::follow_directory_symlink
1106 const std::filesystem::path& directory,
1107 const std::nothrow_t& tag,
1108 std::filesystem::directory_options option = std::filesystem::
1109 directory_options::follow_directory_symlink
1128 const std::filesystem::path& directory,
1129 const std::nothrow_t& tag,
1131 std::filesystem::directory_options option = std::filesystem::
1132 directory_options::follow_directory_symlink
1172 {std::ranges::begin(files), std::ranges::end(files)}
1195 {std::ranges::begin(files), std::ranges::end(files)},
1212 const std::nothrow_t& tag
1216 {std::ranges::begin(files), std::ranges::end(files)},
1234 const std::nothrow_t& tag,
1239 {std::ranges::begin(files), std::ranges::end(files)},
1302 [[nodiscard]]
bool IsOpen() const noexcept;
1334 [[nodiscard]]
bool IsValid() const noexcept;
1395 const std::nothrow_t& tag,
1454 [[nodiscard]]
bool Open(
1456 const std::nothrow_t& tag
1480 [[nodiscard]]
bool Open(
1482 const std::nothrow_t& tag
1529 const std::nothrow_t& tag
1556 const std::nothrow_t& tag
1606 const std::nothrow_t& tag
1643 const std::nothrow_t& tag
1660 const std::filesystem::path& directory,
1661 std::filesystem::directory_options option,
1667 const std::filesystem::path& directory,
1668 const std::nothrow_t& tag,
1669 std::filesystem::directory_options option,
1682 const std::nothrow_t& tag,
1727 const std::
string& type_separator =
" -> "
1756 const std::
string& type_separator =
" -> ",
1757 const std::
string& file_separator =
"\n"
1800 const std::
string& type_separator =
" -> "
1821 const std::
string& type_separator =
" -> ",
1822 const std::
string& file_separator =
"\n"
1869 const std::
string& separator =
", "
1916 const std::
string& value_separator =
": "
1944 const std::
string& value_separator =
": ",
1945 const std::
string& parameter_separator =
", "
PIMPL implementation class for Magic.
Definition magic.cpp:222
static std::string_view DEFAULT_DATABASE_FILE
Path to the default magic database file.
Definition magic.hpp:431
std::vector< Flags > FlagsContainerT
Container type holding a collection of Magic::Flags.
Definition magic.hpp:401
ExpectedFileTypeMapT::value_type ExpectedFileTypeEntryT
Key-value pair representing a single file and its expected file type result.
Definition magic.hpp:275
std::string ErrorMessageT
String type representing an error message from file identification.
Definition magic.hpp:237
FileTypeMapT::value_type FileTypeEntryT
Key-value pair representing a single file and its detected type.
Definition magic.hpp:258
std::expected< FileTypeT, ErrorMessageT > ExpectedFileTypeT
Result type for file identification, containing either a file type or an error message.
Definition magic.hpp:244
FileTypeMapT IdentifyDirectoryImpl(const std::filesystem::path &directory, std::filesystem::directory_options option, ProgressTrackerT progress_tracker=Utility::MakeSharedProgressTracker()) const
Implementation for directory identification (throwing version).
Definition magic.cpp:2550
std::map< std::filesystem::path, FileTypeT > FileTypeMapT
Map from file paths to their detected types.
Definition magic.hpp:251
Utility::SharedProgressTrackerT ProgressTrackerT
Alias for a shared pointer to a progress tracker used for monitoring file identification progress.
Definition magic.hpp:284
std::unique_ptr< MagicPrivate > m_impl
Pointer to the implementation (Pimpl idiom).
Definition magic.hpp:1653
std::map< std::filesystem::path, ExpectedFileTypeT > ExpectedFileTypeMapT
Map from file paths to expected file type results (success or error).
Definition magic.hpp:265
friend std::string ToString(Flags)
Friend declaration for ToString(Flags) free function.
Definition magic.cpp:2355
std::map< Parameters, std::size_t > ParameterValueMapT
Map from Magic::Parameters to their corresponding values.
Definition magic.hpp:408
std::bitset< 30uz > FlagsMaskT
Bitmask type representing a set of Magic::Flags used to configure the Magic instance.
Definition magic.hpp:223
std::vector< std::filesystem::path > DefaultFileContainerT
Default container type for file paths used in implementation.
Definition magic.hpp:1656
ParameterValueMapT::value_type ParameterValueT
Key-value pair representing a single parameter and its value.
Definition magic.hpp:415
std::string FileTypeT
String type representing the detected type of a file.
Definition magic.hpp:230
FileTypeMapT IdentifyContainerImpl(const DefaultFileContainerT &files, ProgressTrackerT progress_tracker=Utility::MakeSharedProgressTracker()) const
Implementation for container identification (throwing version).
Definition magic.cpp:2592
Concept for containers that can hold filesystem paths.
Definition utility.hpp:250
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
FileTypeT IdentifyFile(const std::filesystem::path &path) const
Identify the type of a single file.
Definition magic.cpp:2530
ExpectedFileTypeMapT IdentifyFiles(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 all files in a directory (noexcept version).
Definition magic.hpp:1105
FileTypeMapT IdentifyFiles(const std::filesystem::path &directory, ProgressTrackerT progress_tracker, std::filesystem::directory_options option=std::filesystem::directory_options::follow_directory_symlink) const
Identify all files in a directory with progress tracking.
Definition magic.hpp:1082
ExpectedFileTypeMapT IdentifyFiles(const Utility::FileContainer auto &files, const std::nothrow_t &tag, ProgressTrackerT progress_tracker) const noexcept
Identify multiple files with progress tracking (noexcept version).
Definition magic.hpp:1232
FileTypeMapT IdentifyFiles(const Utility::FileContainer auto &files) const
Identify multiple files from a container.
Definition magic.hpp:1167
ExpectedFileTypeMapT IdentifyFiles(const std::filesystem::path &directory, const std::nothrow_t &tag, ProgressTrackerT progress_tracker, std::filesystem::directory_options option=std::filesystem::directory_options::follow_directory_symlink) const noexcept
Identify all files in a directory with progress tracking (noexcept version).
Definition magic.hpp:1127
FileTypeMapT IdentifyFiles(const std::filesystem::path &directory, std::filesystem::directory_options option=std::filesystem::directory_options::follow_directory_symlink) const
Identify all files in a directory.
Definition magic.hpp:1037
ExpectedFileTypeMapT IdentifyFiles(const Utility::FileContainer auto &files, const std::nothrow_t &tag) const noexcept
Identify multiple files from a container (noexcept version).
Definition magic.hpp:1210
FileTypeMapT IdentifyFiles(const Utility::FileContainer auto &files, ProgressTrackerT progress_tracker) const
Identify multiple files with progress tracking.
Definition magic.hpp:1189
FlagsContainerT GetFlags() const
Get the current flags.
Definition magic.cpp:2488
void SetFlags(FlagsMaskT flags_mask)
Set new flags for the Magic instance.
Definition magic.cpp:2674
void Close() noexcept
Close the Magic instance.
Definition magic.cpp:2476
static bool Compile(const std::filesystem::path &database_file=DEFAULT_DATABASE_FILE) noexcept
Compile a magic database file.
Definition magic.cpp:2481
Flags
Flags for configuring Magic behavior.
Definition magic.hpp:314
Parameters
Parameters for tuning Magic behavior limits.
Definition magic.hpp:381
@ Mime
Definition magic.hpp:328
@ NoCheckCompress
Definition magic.hpp:334
@ NoCheckCdf
Definition magic.hpp:340
@ Devices
Definition magic.hpp:320
@ NoCheckSimh
Definition magic.hpp:345
@ NoCheckJson
Definition magic.hpp:344
@ Apple
Definition magic.hpp:329
@ NoCheckTar
Definition magic.hpp:335
@ Extension
Definition magic.hpp:330
@ NoCheckEncoding
Definition magic.hpp:343
@ Compress
Definition magic.hpp:319
@ NoCheckApptype
Definition magic.hpp:337
@ NoCheckTokens
Definition magic.hpp:342
@ NoCheckElf
Definition magic.hpp:338
@ Raw
Definition magic.hpp:325
@ CheckDatabase
Definition magic.hpp:323
@ ContinueSearch
Definition magic.hpp:322
@ MimeEncoding
Definition magic.hpp:327
@ Error
Definition magic.hpp:326
@ NoCheckCsv
Definition magic.hpp:341
@ NoCheckText
Definition magic.hpp:339
@ Nodesc
Definition magic.hpp:333
@ CompressTransp
Definition magic.hpp:331
@ Symlink
Definition magic.hpp:318
@ Debug
Definition magic.hpp:317
@ None
Definition magic.hpp:316
@ PreserveAtime
Definition magic.hpp:324
@ NoCompressFork
Definition magic.hpp:332
@ MimeType
Definition magic.hpp:321
@ NoCheckBuiltin
Definition magic.hpp:346
@ NoCheckSoft
Definition magic.hpp:336
@ IndirMax
Definition magic.hpp:383
@ ElfShnumMax
Definition magic.hpp:386
@ EncodingMax
Definition magic.hpp:390
@ ElfShsizeMax
Definition magic.hpp:391
@ NameMax
Definition magic.hpp:384
@ MagWarnMax
Definition magic.hpp:392
@ ElfPhnumMax
Definition magic.hpp:385
@ RegexMax
Definition magic.hpp:388
@ BytesMax
Definition magic.hpp:389
@ ElfNotesMax
Definition magic.hpp:387
std::shared_ptr< ProgressTracker > SharedProgressTrackerT
Shared pointer type for ProgressTracker.
Definition progress_tracker.hpp:405
void Open(FlagsMaskT flags_mask)
Open Magic with specified flags.
Definition magic.cpp:2651
ParameterValueMapT GetParameters() const
Get all parameter values.
Definition magic.cpp:2513
std::size_t GetParameter(Parameters parameter) const
Get the value of a specific parameter.
Definition magic.cpp:2500
void SetParameter(Parameters parameter, std::size_t value)
Set a single parameter value.
Definition magic.cpp:2697
void SetParameters(const ParameterValueMapT ¶meters)
Set multiple parameter values.
Definition magic.cpp:2711
bool IsValid() const noexcept
Check if the Magic instance is valid for file identification.
Definition magic.cpp:2633
bool IsOpen() const noexcept
Check if the Magic instance is open.
Definition magic.cpp:2628
bool IsDatabaseLoaded() const noexcept
Check if a magic database is loaded.
Definition magic.cpp:2623
static std::string GetVersion() noexcept
Get the libmagic library version.
Definition magic.cpp:2525
static bool Check(const std::filesystem::path &database_file=DEFAULT_DATABASE_FILE) noexcept
Check magic database file for validity.
Definition magic.cpp:2469
Exception hierarchy for the Magic file identification library.
Utility components for the libmagicxx library.
Definition percentage.hpp:39
Root namespace for the libmagicxx library.
Thread-safe progress tracking for batch file operations.
Utility concepts, classes, and functions for the Magic library.