class Magic::Magic

Defined in:

magic/magic.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(flags : MagicFlags) #

[View source]

Instance Method Detail

def buffer(buf : Bytes) #

Returns a textual description of the contents of the argument passed as a buffer or Nil if an error occurred and the MagicFlags::ERROR flag is set. A call to errno() will return the numeric error code.


[View source]
def buffer(buf : String) #

Returns a textual description of the contents of the argument passed as a buffer or Nil if an error occurred and the MagicFlags::ERROR flag is set. A call to errno() will return the numeric error code.


[View source]
def check(dbs : String) #

Check the validity of entries in the colon separated list of database files passed as argument or the default database file if no argument.


[View source]
def close #

Closes the magic database and deallocates any resources used.


[View source]
def compile(dbs : String) #

Compile entries in the colon separated list of database files passed as argument or the default database file if no argument. The compiled files created are named from the basename(1) of each file argument with ".mgc" appended to it.


[View source]
def descriptor(file : File) #

Returns a textual description of the contents of the argument passed as a file or Nil if an error occurred and the MagicFlags::ERROR flag is set. A call to errno() will return the numeric error code.


[View source]
def errno #

Returns a numeric error code. If return value is 0, an internal magic error occurred. If return value is non-zero, the value is an OS error code. Use the errno module or os.strerror() can be used to provide detailed error information.


[View source]
def error #

Returns a textual explanation of the last error or Nil if there was no error.


[View source]
def file(filename) #

Returns a textual description of the contents of the argument passed as a filename or Nil if an error occurred and the MagicFlags::ERROR flag is set. A call to errno() will return the numeric error code.


[View source]
def get_param(param : MagicParam) #

Returns the param value if successful, raises if param was unknown


[View source]
def list(dbs : String) #

[View source]
def load(filename = nil) #

Must be called to load entries in the colon separated list of database files passed as argument or the default database file if no argument before any magic queries can be performed.


[View source]
def set_flags(flags : MagicFlags) #

Set flags on the magic object which determine how magic checking behaves; a bitwise OR of the flags described in libmagic(3). Raises on systems that don't support utime(2) or utimes(2) when MagicFlags::PRESERVE_ATIME is set.


[View source]
def set_param(param : MagicParam) #

Returns true if successful


[View source]