magic
CopyrightCopyright (C) 2005 John Goerzen
LicenseBSD-3-Clause
MaintainerPhilippe <philippedev101\@gmail.com>
Stabilityprovisional
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Magic.Init

Description

Creating a magic handle and loading magic databases into it. A handle returned by magicOpen must be given a database with magicLoadDefault or magicLoad before it can be queried with the functions in Magic.Operations.

Written by John Goerzen.

Synopsis

Documentation

magicOpen :: MagicFlags -> IO Magic Source #

Create a new magic handle configured with the given flags. Combine flags with (<>) (see MagicFlags), or pass mempty for the defaults. Before querying anything you must load a database with magicLoadDefault or magicLoad.

The handle is freed automatically when it is garbage-collected. Raises an IOError if the handle cannot be created.

magicLoad :: Magic -> [OsPath] -> IO () Source #

Load the given magic database(s) into the handle. Pass the empty list to load the system default (equivalent to magicLoadDefault). Raises a MagicException if a database cannot be loaded.

(libmagic joins the list with the platform search-path separator, so a path that itself contains that separator cannot be represented.)

magicLoadDefault :: Magic -> IO () Source #

Load the system's default magic database into the handle. Raises a MagicException if the database cannot be loaded.