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

Magic.Data

Description

The MagicFlags bit-mask, mapping the C libmagic MAGIC_* constants to Haskell. Flags are combined with (<>), tested with hasFlag, and narrowed with removeFlags; the empty set (mempty) is MagicNone.

Synopsis

Documentation

newtype MagicFlags Source #

A set of libmagic flags, represented as the underlying C bit-mask. Combine flags with (<>), start from mempty (no flags), test membership with hasFlag, and narrow with removeFlags. The MagicFlags constructor is an escape hatch for passing a raw mask; prefer the pattern synonyms below.

Since: 2.0.0

Constructors

MagicFlags CInt 

Instances

Instances details
NFData MagicFlags Source # 
Instance details

Defined in Magic.Data

Methods

rnf :: MagicFlags -> ()

Monoid MagicFlags Source #

mempty is the empty flag set (MagicNone).

Instance details

Defined in Magic.Data

Semigroup MagicFlags Source #

Flags combine by bitwise-or.

Instance details

Defined in Magic.Data

Methods

(<>) :: MagicFlags -> MagicFlags -> MagicFlags

sconcat :: NonEmpty MagicFlags -> MagicFlags

stimes :: Integral b => b -> MagicFlags -> MagicFlags

Generic MagicFlags Source # 
Instance details

Defined in Magic.Data

Associated Types

type Rep MagicFlags 
Instance details

Defined in Magic.Data

type Rep MagicFlags = D1 ('MetaData "MagicFlags" "Magic.Data" "magic-2.0.0-A9TYcUdA1HUI3Y62VpQyfB" 'True) (C1 ('MetaCons "MagicFlags" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CInt)))

Methods

from :: MagicFlags -> Rep MagicFlags x

to :: Rep MagicFlags x -> MagicFlags

Show MagicFlags Source #

Prints the set flags by name (e.g. MagicMimeType <> MagicError), or MagicNone when empty. Any bits not corresponding to a known flag are shown as a raw MagicFlags n term.

Instance details

Defined in Magic.Data

Methods

showsPrec :: Int -> MagicFlags -> ShowS

show :: MagicFlags -> String

showList :: [MagicFlags] -> ShowS

Eq MagicFlags Source # 
Instance details

Defined in Magic.Data

Methods

(==) :: MagicFlags -> MagicFlags -> Bool

(/=) :: MagicFlags -> MagicFlags -> Bool

Ord MagicFlags Source # 
Instance details

Defined in Magic.Data

type Rep MagicFlags Source # 
Instance details

Defined in Magic.Data

type Rep MagicFlags = D1 ('MetaData "MagicFlags" "Magic.Data" "magic-2.0.0-A9TYcUdA1HUI3Y62VpQyfB" 'True) (C1 ('MetaCons "MagicFlags" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CInt)))

hasFlag :: MagicFlags -> MagicFlags -> Bool Source #

hasFlag fs flag is True when every bit of flag is set in fs. Works for composite flags too (e.g. fs `hasFlag` MagicMime). Note that fs `hasFlag` MagicNone is always True (the empty set is a subset of everything).

Since: 2.0.0

removeFlags :: MagicFlags -> MagicFlags -> MagicFlags Source #

removeFlags fs drop clears every bit of drop from fs (set difference), e.g. flags `removeFlags` MagicError.

Since: 2.0.0

pattern MagicNone :: MagicFlags Source #

No special handling; return a textual description (the default). This is mempty.

pattern MagicDebug :: MagicFlags Source #

Print debugging messages to stderr.

pattern MagicSymlink :: MagicFlags Source #

Follow symbolic links.

pattern MagicCompress :: MagicFlags Source #

Look inside compressed files.

pattern MagicDevices :: MagicFlags Source #

Look at the contents of block or character special devices.

pattern MagicMimeType :: MagicFlags Source #

Return a MIME type string instead of a textual description.

pattern MagicMimeEncoding :: MagicFlags Source #

Return the MIME encoding (character set) instead of a textual description.

pattern MagicMime :: MagicFlags Source #

Return both the MIME type and the encoding (MagicMimeType <> MagicMimeEncoding).

pattern MagicContinue :: MagicFlags Source #

Return all matches, not just the first.

pattern MagicCheck :: MagicFlags Source #

Check the magic database for consistency and report problems.

pattern MagicPreserveAtime :: MagicFlags Source #

Preserve the access time of examined files.

pattern MagicRaw :: MagicFlags Source #

Do not translate unprintable characters to octal escapes.

pattern MagicError :: MagicFlags Source #

Treat errors while examining a file as real errors instead of embedding them in the result.

pattern MagicApple :: MagicFlags Source #

Return the Apple creator and type.

pattern MagicExtension :: MagicFlags Source #

Return a slash-separated list of valid file extensions for the detected type.

pattern MagicCompressTransp :: MagicFlags Source #

Report on the compressed contents only, without mentioning the compression itself (transparent decompression).

pattern MagicNoCompressFork :: MagicFlags Source #

Do not allow decompression that requires forking a helper process.

pattern MagicNodesc :: MagicFlags Source #

Composite of MagicExtension, MagicMime and MagicApple: return identifiers rather than a textual description.

pattern MagicNoCheckCompress :: MagicFlags Source #

Do not look inside compressed files.

pattern MagicNoCheckTar :: MagicFlags Source #

Do not examine tar archives.

pattern MagicNoCheckSoft :: MagicFlags Source #

Do not consult the magic database entries (soft magic).

pattern MagicNoCheckApptype :: MagicFlags Source #

Do not check for an application type (e.g. EMX).

pattern MagicNoCheckElf :: MagicFlags Source #

Do not examine ELF details.

pattern MagicNoCheckText :: MagicFlags Source #

Do not examine text files.

pattern MagicNoCheckCdf :: MagicFlags Source #

Do not examine CDF (Microsoft Compound Document) files.

pattern MagicNoCheckCsv :: MagicFlags Source #

Do not examine CSV files.

pattern MagicNoCheckTokens :: MagicFlags Source #

Do not look for known text tokens.

pattern MagicNoCheckEncoding :: MagicFlags Source #

Do not check text encodings.

pattern MagicNoCheckJson :: MagicFlags Source #

Do not examine JSON files.

pattern MagicNoCheckSimh :: MagicFlags Source #

Do not examine SIMH tape files.

pattern MagicNoCheckBuiltin :: MagicFlags Source #

Disable all built-in tests; consult only the magic database.