Re: package proposal: MIME_ContentType
| From: | Yavor Shahpasov | Date: | Sun, 15 Jun 2003 13:09:08 +0000 |
| Subject: | Re: package proposal: MIME_ContentType | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-17485@lists.php.net to get a copy of this message | ||
+1
it looks like a usefull addition, some notes though,
it should come with it's own mime.types file which should go into pear/data,
instead of relying on a file only found on unix machines
second I see some unneeded overhead in the constructor
addTypes would call scanTypes with '/etc/mime.types'
and rescanTypes would do exactly the same, causing the same code to be
executed twise, correct me if am wrong thow.
i see a small problem in this
function MIME_ContentType($mimedb = '/etc/mime.types') {
$this->addTypes($mimedb);
$this->rescanTypes();
}
function addTypes($types) {
if (!is_readable($types)) {
// FIXME
}
$this->_mimeTypes[] = $types;
$this->scanTypes($types);
}
function rescanTypes() {
unset($this->_forward);
unset($this->_reverse);
foreach ($this->_mimeTypes as $file)
$this->scanTypes($file);
}
from the above it seems that on constructor scanTypes would be called two
times with the same file, i don't know but it seems like a few lost CPU
cycles to me
Yavor
----- Original Message -----
From: "Martin Jansen" <mj@php.net>
To: "Ian Eure" <ieure@debian.org>
Cc: <pear-dev@lists.php.net>
Sent: Saturday, June 14, 2003 4:35 PM
Subject: Re: [PEAR-DEV] package proposal: MIME_ContentType
> On Wed Jun 11, 2003 at 12:4833PM -0700, Ian Eure wrote:
> > MIME_ContentType is a PEAR package for looking up a file's mimetype.
> >
> > Features:
> > * Uses the system's mime database (/etc/mime.types) by default
> > * Can find the mime-type for a file extension. (forward lookup)
> > * Can find valid extensions for a mime-type (backward lookup)
> > * MIME types may be added and removed.
> > * New mime.types file may be written containing all the types
MIME_ContentType
> > knows about.
> >
> > It's under the PHP license, and the code is available for review at
> > http://people.debian.org/~ieure/ContentType.phps
>
> I'm +1 on this. But why is the class derived from PEAR? I don't see a
> need for this ...
>
> --
> - Martin Martin Jansen
> http://martinjansen.com/
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>