[plt-scheme] Guessing the file type?

From: Amit Saha (lists.amitsaha at gmail.com)
Date: Sun Jul 26 23:54:23 EDT 2009

Hello Jay,

Jay McCarthy wrote:
> make-path->mime-type takes a path to the MIME database (such as
> /private/etc/apache2/mime.types on OS X) returns a procedure than when
> given a path will return the mime type. It is basically building a
> cache to get mime types fast.

Great. On my Ubuntu Linux:

 > ((make-path->mime-type "/etc/mime.types") (build-path 
"/home/r00t/Music/" "m.mp3"))
#"audio/mpeg"

does it.

Now wondering: How would I go about writing code, such as this- to work 
on Linux as well as say, a Mac OSX ?

Thanks a ton, already.

Best,
Amit
> 
> Jay
> 
> On Sun, Jul 26, 2009 at 9:40 AM, Amit Saha<lists.amitsaha at gmail.com> wrote:
>> Amit Saha wrote:
>>> Jay McCarthy wrote:
>>>> On Unix/OS X there is a program called 'file' that works pretty well.
>>> Yep. I was looking for a plt-scheme interface..
>>>
>>>> Also, if you use the mime type library in the PLT Web server, it uses
>>>> the system database of file extensions to return a mime type.
>>> Yeah..I came across this. However, I thought of consulting the list to
>>> enquire if there was another way..
>>
>> I have used 'make-path->mime-type' which gives back a procedure for the
>> relevant MIME type. For eg:
>>
>>> (make-path->mime-type (build-path "/home/r00t/Music/" "m.mp3"))
>> #<procedure:...rivate/mime-types.ss:9:44>
>>
>>
>> Not sure, how can I obtain the MIME type now? I can see: make-get-mime-type
>> : path? -> path? -> bytes? in private/mime-types.ss. Again not sure, how it
>> can be used..
>>
>> Please suggest.
>>
>> Best,
>> Amit
>> --
>> email: amitsaha.in at gmail.com
>> Journal: http://amitksaha.wordpress.com
>> µ-blog: http://twitter.com/amitsaha
>> IRC: cornucopic on #scheme, #lisp, #math, #linux
>> _________________________________________________
>>  For list-related administrative tasks:
>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>>
> 
> 
> 


-- 
email: amitsaha.in at gmail.com
Journal: http://amitksaha.wordpress.com
µ-blog: http://twitter.com/amitsaha
IRC: cornucopic on #scheme, #lisp, #math, #linux


Posted on the users mailing list.