Reimplementation of ruby-filemagic gem (uses FFI)
License
glongman/ffiruby-filemagic
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
ffiruby-filemagic ================= Win32 Support? sorry. A new implementation of the ancient ruby-filemagic gem (http://grub.ath.cx/filemagic/). This version uses FFI to talk to the native library (JRuby friendly). (Blurb from the original gem site follows) What is FileMagic? FileMagic is a Ruby binding to the magic(4) library, which you may know better as the file(1) command. The file command identifies the type of a file using, among other tests, a test for whether the file begins with a certain magic number. Install: Make sure you have the magic(4) library installed. > sudo gem sources -a http://gems.github.com > sudo gem install glongman-ffiruby-filemagic After Install: > sudo ffi_file_magic_setup > irb >> require 'ffi_file_magic' => true >> fm = FFIFileMagic.new(FFIFileMagic::MAGIC_MIME) => #<FFIFileMagic:0x11a4d9c @cookie=#<Native Pointer address=0x13606f0>> >> fm.file('rails.png') #supply a path to your own image => "image/png" >> Install Problems? If the gem complains that it can't find the magic library you can run this tool: > sudo ffi_file_magic_setup Without any arguments the tool will look around the filesystem for a magic library and test to see if that library is compatible. If so a small modification will be made so the gem will work. You can run the tool more than once. you can also tell it exactly where to look for the magic libary > sudo ffi_file_magic_setup --with-magic-lib=/opt/local/lib This gem has been tested with the magic library shipped with File 4.26 from ftp://ftp.astron.com/pub/file On OSX, and at the time of writing this, you can get file using macports (http://www.macports.org/) > sudo port install file On other Unix variants, download the source, build and install. then run the tool again COPYRIGHT ========= Copyright (c) 2009 Overlay TV. See LICENSE for details.
About
Reimplementation of ruby-filemagic gem (uses FFI)
Resources
License
Stars
Watchers
Forks
Packages 0
No packages published