[haiku-development] Re: How to Identify a file?

  • From: Fredrik Modéen <fredrik@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 18 Oct 2007 11:09:37 +0200 (CEST)

> Hi,
>
> Fredrik Modéen schrieb:
>>>> I'm looking for a "easy" way of identify what type of file a specific
>>>> entry_ref are. thought BFile could give me that but didn't find it.
>>>>
>>>> I want to make the Media Player "see" different files. If I drop
>>>> files on
>>>> the Media Player I don't want png files etc to be added to the play
>>>> list
>>>> and If I drop a saved play list on the Media Player I want different
>>>> things happen than with mp3 file.
>>>>
>>>> I was thinking of suporting
>>>> - m3u list
>>>> - Zeta play list
>>>> - perhaps our own? don't know how that one would look like..
>>> The mime type of a file should provide that information.
>> thanks..
>> this was the way I found it to work.. any suggestions on how to make it
>> smaller/ not that memory intense? I will move the code to it's own
>> bool VerifyFileType(entry_ref *ref, char *type) function. How do I make
>> char *type that can be more than 1 parameter? I want to send both
>> "audio",
>> "video" and perhaps other super types? But this works nicely :)
>>
>> refsReceivedMessage are a BMessage and can have one file or allot of
>> files. Are hosted in src/apps/mediaplayer/playlist/Playlist.cpp around
>> line 278
>>
>> entry_ref ref;
>> BFile *file;
>> BNodeInfo *nodeinfo;
>> BMimeType* mimetype, temp;
>> char str[10];
>> for (int i = 0; refsReceivedMessage->FindRef("refs", i, &ref) == B_OK;
>> i++){
>>      file = new BFile(&ref, B_READ_ONLY);
>>      nodeinfo = new BNodeInfo(file);
>>      if(nodeinfo->GetType(str) == B_OK){
>>              mimetype = new BMimeType(str);
>>              if(mimetype->GetSupertype(&temp) == B_OK){
>>                      if(temp == "audio" || temp == "video")
>>                              AppendToPlaylistRecursive(ref, playlist);
>>              }
>>      }
>> }
>>
>>> Regards,
>>> Michael
>
>
> Shouldn't it handle folders as well?
AppendToPlaylistRecursive handles that as it iterates thou them :)

>
> Regards,
> Julun
>
>


-- 
MVH
Fredrik Modéen


Other related posts: