0.0
No release in over 3 years
Low commit activity in last 3 years
FFI binding for libmagic.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 1
 Project Readme

Ruby FFI bindings for libmagic

Usage

>> require 'ffi-magic'
=> true
>> magic = Magic.new
=> #<Magic:0x000000012e5ff8 @flags=0, @path=nil, @cookie=#<FFI::Pointer address=0x000000017e38b0>>
>> magic.file('spec/magic.png')
=> "PNG image data, 100 x 67, 8-bit/color RGB, non-interlaced"
>> magic.flags = Magic::MIME_TYPE
=> 16
>> magic.file('spec/magic.png')
=> "image/png"

Getting the MIME Type

magic = Magic.new(Magic::MIME)
=> #<Magic:0x00000000a3cc80 @flags=1040, @path=nil, @cookie=#<FFI::Pointer address=0x00000000df7190>>
>> magic.file('spec/magic.png')
>> => "image/png; charset=binary"