osx - Scanning a disk for files quickly with progress bar -


i need search folder (and sub folders) files. needs done possible , need able display progress indicator user.

to display progress indicator need retrieve, example, total number of folders underneath folder being searched. way can count sub folders scan them , report useful user.

is information available somewhere?

note functionality disks aren't indexed using spotlight. spotlight indexed drives run nsmetadataquery.

for actual scan can use cocoa classes, such nsdirectoryenumerator, or lower-level facilities, such fts - there multiple ways pick suits best.

the more interesting part progress indicator. file system not maintain "child" count folder, i.e. count of children, grandchildren, great grandchildren, etc. number of files on whole volume available, e.g. see statfs.

the number of items in particular folder quick , easy determine; e.g. nsfilemanager's contentsofdirectoryatpath:error: returns array, fts routines return linked list, , can work out use hard link count - obtainable via nsurl's getresourcevalue:forkey:error:. using such methods on entry directory can add child count total, scan tree maintain both number of items processed , known number need processed. ui can of form "n of m" both can increase.

if don't number of items in whole tree requires (pre)scanning tree, takes amount of time (you can see in finder - select folder, closer root of disk better, , info , see pause while information collected). not hard using of scanning methods mentioned above. have consider time/value/memory tradeoff - e.g. while can produce list of all items in tree (a directory enumerator give that) count , process 1 item @ time risk having large memory footprint , pause before @ happens - pause see in finder's info window).

so goal of "quickly progress bar" challenge.

hth


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -