On Thu, Jan 6, 2011 at 3:54 PM, Abhinav Tyagi <abhityag...@gmail.com> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to