Gauche-magic Reference Manual

For version 0.1.2

last update: Sun Dec 16 2007

http://www.fixedpoint.jp/gauche-magic/

API

class: <magic-set>

An object of the class wraps a C's magic_t.


class: <magic-error>

A libmagic-origin error will be raised as a instance of the class.

It has two slots: "no" and "message". The former indicates a magic-specific errno.


variable: MAGIC_NONE

variable: MAGIC_DEBUG

variable: MAGIC_SYMLINK

variable: MAGIC_COMPRESS

variable: MAGIC_DEVICES

variable: MAGIC_MIME

variable: MAGIC_CONTINUE

variable: MAGIC_CHECK

variable: MAGIC_PRESERVE_ATIME

variable: MAGIC_RAW

variable: MAGIC_ERROR

These are integers corresponding to their C-alternatives and mutually exclusive on logical-and.

A flag argument of magic-open may be a logical-or of these.


procedure: magic-open flags

Return a <magic-set> with given `flags', or #f if an error occurs.


procedure: magic-close ms

Close the <magic-set> `ms'. It is preferable but optional since gc works in the long run.


procedure: magic-load ms path

Load a magic database at `path'.


procedure: magic-check ms path

procedure: magic-compile ms path

Check or compile a magic database at `path'.

Given `ms' must have flags with MAGIC_CHECK on, an error if not.


procedure: magic-file ms path

Return the description of the file `path' as a string, or #f if an error occurs.


parameter: default-magic-file

Return the path of the default database file, e.g. /usr/share/file/magic.


procedure: call-with-magic-set proc &keyword db flags

Call `proc' with a <magic-set> whose flags are `flags' as a single argument.

If `flags' with MAGIC_CHECK off (default), before doing that it loads a magic wisdom which is either the `db' or a default one unless specified.

Returning with an error or without, it closes the <magic-set>.


© 2006,2007 Takeshi Abe