mmmagic: async file type detection goodness

126 views
Skip to first unread message

mscdex

unread,
Apr 30, 2012, 3:15:07 AM4/30/12
to nodejs
I recently needed a way to do file type detection/inspection, but felt
dirty using a child process to call `file` every time. So tonight I
sat down and wrote an async binding to libmagic: https://github.com/mscdex/mmmagic

Currently it's available for *nix only, although a pull request for
proper (read: builds with msvc) Windows support would be considered.
The only other requirement is zlib.

I expect to be adding support for raw Buffer and string inspection/
parsing in the near future.

Marak Squires

unread,
Apr 30, 2012, 3:21:35 AM4/30/12
to nod...@googlegroups.com
Super awesome!

I've been working on some mad science projects that are doing massive amounts of file detection. I'm assuming this will destroy the performance of my all JS hackery.

Looking forward to trying...


--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com
To unsubscribe from this group, send email to
nodejs+un...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en



--
-- 
Marak Squires
Co-founder and Chief Evangelist
Nodejitsu, Inc.

Nathan Rajlich

unread,
Apr 30, 2012, 12:49:08 PM4/30/12
to nod...@googlegroups.com
-1 point for still using a wscript file :p

You're already bundling libmagic so Windows support might be easy. You'd need to start out with adding a binding.gyp file so that the module can be built with node-gyp.

mscdex

unread,
Apr 30, 2012, 1:34:14 PM4/30/12
to nodejs
On Apr 30, 12:49 pm, Nathan Rajlich <nat...@tootallnate.net> wrote:
> -1 point for still using a wscript file :p
>
> You're already bundling libmagic so Windows support might be easy. You'd
> need to start out with adding a binding.gyp file so that the module can be
> built with node-gyp.

Yeah, I rarely write C++ addons, so I'm not quite familiar with the
gyp stuff yet. I'll get to adding a gyp file for mmmagic soon enough
though.

My main concerns about Windows compatibility were mostly to do with
libmagic itself, as it does have some *nix-only features like the
option to use a file descriptor for content type detection and
whatnot. I'll probably have to end up manually removing that stuff I
guess.

mscdex

unread,
Apr 30, 2012, 4:56:37 PM4/30/12
to nodejs
On Apr 30, 3:15 am, mscdex <msc...@gmail.com> wrote:
> I expect to be adding support for raw Buffer and string inspection/
> parsing in the near future.

Done. Buffer inspection now available in v0.0.2 :-)

Rajesh Kumar Jha

unread,
Apr 30, 2012, 1:15:15 PM4/30/12
to nod...@googlegroups.com
Can you tell me how event driven programming minimizing request and saving call to server.

In languages like Java™ and PHP, each connection spawns a new thread that potentially has an accompanying 2 MB of memory with it. On a system that has 8 GB of RAM, that puts the theoretical maximum number of concurrent connections at about 4,000 users.

how node helping us.
With regards
Er. Rajesh Kumar Jha
Software Engineer
mail : rkjha.it.in@gmail.com
Ph : +91-9560034877,7428444177

mscdex

unread,
May 4, 2012, 8:54:00 PM5/4/12
to nodejs
..... and v0.1.0 now has Windows support (no compiler or special
dependencies needed)! :-)
Reply all
Reply to author
Forward
0 new messages