Re: LOCATING MEDIA FILES IN MACINTOSH
Re: LOCATING MEDIA FILES IN MACINTOSH
- Subject: Re: LOCATING MEDIA FILES IN MACINTOSH
- From: Sherm Pendley <email@hidden>
- Date: Thu, 6 Jan 2011 16:33:44 -0500
On Thu, Jan 6, 2011 at 3:54 PM, Abhinav Tyagi <email@hidden> wrote:
>
> Problem: Scanning the disc for media files. As the media files can be
> present anywhere
> in the disc, searching whole disc by enumerating the directory listings will
> be very tedious
> i guess (like combining ls and grep in the terminal).
Yes, it's repetitive and rather tedious - but fortunately computers
don't get bored. :-)
> 1) I need an efficient approach to solve this problem using Cocoa or C++.
Try the easy approach first - a simple recursive search enumerating
directory entries. If profiling your app shows that to be a meaningful
bottleneck, *then* look for a more efficient and "clever" approach.
Premature optimization is the root of all evil.
> 2) How will check a file if its a valid media file or data file. Like we can
> have ".dat" files that
> are video files but data files can also have ".dat" extension. not much
> significant. Is there
> api that can tell whether a file is media file or not? (not soooo
> important).
The "file" command looks for "magic numbers" within the file, as
described in the files in /usr/share/file/magic/. The format of these
files is documented in "man magic", and it's pretty straightforward.
sherm--
--
Cocoa programming in Perl:
http://camelbones.sourceforge.net
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden