magic
Source: quickjs-magic.c — module export: Magic
Bindings to libmagic (the file(1) library) for content-type detection. The
instance is also callable.
Constructor
new Magic([flags]) // length 1Methods
| Method | Args | Description |
|---|---|---|
descriptor(fd) | 1 | Identifies the content read from a file descriptor. |
file(path) | 1 | Identifies the content of a file by path. |
buffer(data) | 1 | Identifies the content of an in-memory buffer. |
getflags() | 0 | Returns the active flags. |
setflags(flags) | 1 | Sets the active flags (Magic.MIME, etc.). |
check(path) | 1 | Checks the validity of a magic database. |
compile(path) | 1 | Compiles a magic database. |
list(path) | 1 | Lists entries in a magic database. |
load([path]) | 0 | Loads a magic database. |
getparam(param) | 2 | Reads a libmagic parameter (Magic.PARAM_*). |
setparam(param, value) | 2 | Sets a libmagic parameter. |
Properties (read-only)
| Property | Description |
|---|---|
error | Last error string. |
errno | Last error number. |
version | libmagic version. |
Static constants
Flags: NONE, DEBUG, SYMLINK, COMPRESS, DEVICES, MIME_TYPE,
CONTINUE, CHECK, PRESERVE_ATIME, RAW, ERROR, MIME_ENCODING, MIME,
APPLE, EXTENSION, COMPRESS_TRANSP, NODESC, and the NO_CHECK_* family.
Parameters: PARAM_INDIR_MAX, PARAM_NAME_MAX, PARAM_ELF_PHNUM_MAX,
PARAM_ELF_SHNUM_MAX, PARAM_ELF_NOTES_MAX, PARAM_REGEX_MAX,
PARAM_BYTES_MAX. Also VERSION and DEFAULT_DB.
Export list
Generated by utilities/doc-api.js from the magic dump of utilities/api-surface.sh: 58 members. Edit the text above this block, not the block.
Magic
class, constructible
- static values:
APPLE = 2048,CHECK = 64,COMPRESS = 4,COMPRESS_TRANSP = 33554432,CONTINUE = 32,DEBUG = 1,DEFAULT_DB,DEVICES = 8,ERROR = 512,EXTENSION = 16777216,MIME = 1040,MIME_ENCODING = 1024,MIME_TYPE = 16,NODESC = 16780304,NONE = 0,NO_CHECK_APPTYPE = 32768,NO_CHECK_ASCII = 131072,NO_CHECK_BUILTIN = 16756736,NO_CHECK_CDF = 262144,NO_CHECK_COMPRESS = 4096,NO_CHECK_CSV = 524288,NO_CHECK_ELF = 65536,NO_CHECK_ENCODING = 2097152,NO_CHECK_FORTRAN = 0,NO_CHECK_JSON = 4194304,NO_CHECK_SOFT = 16384,NO_CHECK_TAR = 8192,NO_CHECK_TEXT = 131072,NO_CHECK_TOKENS = 1048576,NO_CHECK_TROFF = 0,PARAM_BYTES_MAX = 6,PARAM_ELF_NOTES_MAX = 4,PARAM_ELF_PHNUM_MAX = 2,PARAM_ELF_SHNUM_MAX = 3,PARAM_INDIR_MAX = 0,PARAM_NAME_MAX = 1,PARAM_REGEX_MAX = 5,PRESERVE_ATIME = 128,RAW = 256,SYMLINK = 2,VERSION = 545 - methods:
buffer(),check(),compile(),descriptor(),file(),getflags(),getparam(),list(),load(),setflags(),setparam() - properties:
errno (get),error (get),version (get),[Symbol.toStringTag]