[haiku-development] Re: Thanks

  • From: "Axel Dörfler" <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 18 Oct 2007 13:25:42 +0200 CEST

Fredrik Modéen <fredrik@xxxxxxxxx> wrote:
>         char mimeString[B_MIME_TYPE_LENGTH];
>         if (nodeInfo.GetType(mimeString) != B_OK)
>               return false;

BTW, I would replace this with:

        char mimeString[B_MIME_TYPE_LENGTH];
        if (nodeInfo.GetType(mimeString) != B_OK) {
                BMimeType type;
                if (BMimeType::GuessMimeType(ref, &type) != B_OK)
                        return false;

                strlcpy(mimeString, type.Type(), B_MIME_TYPE_LENGTH);
                nodeInfo.SetType(type.Type());
        }

This will also work on file systems that don't support attributes, or
on not yet sniffed files.
The SetType() is optional and would only attach a type for files that
don't have one yet on BFS.

Bye,
   Axel.


Other related posts: