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

  • From: Stephan Assmus <superstippi@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Thu, 18 Oct 2007 12:30:13 +0200

Fredrik Holmqvist wrote (2007-10-18, 12:09:34 [+0200]):
> It could also be a lot less nested by using the continue keyword:
>
> entry_ref ref;
> for (int i = 0; refsReceivedMessage->FindRef("refs", i, &ref) == B_OK; 
> i++) {
>         BFile file(&ref, B_READ_ONLY);
>         BNodeInfo nodeInfo(&file);
>         char mimeString[B_MIME_TYPE_LENGTH];
>          if (nodeInfo->GetType(mimeString) != B_OK)
>              continue;
> 
>          BMimeType fileType(mimeString);
>          BMimeType superType;
>          if (fileType->GetSupertype( &superType) != B_OK)
>              continue;
> 
>          if (superType == "audio" || superType == "video")
>              AppendToPlaylistRecursive(ref, playlist);
> }

Yep, I am actually a fan of this "least-nested style" myself.

Best regards,
-Stephan

Other related posts: