appletprioritydiskloop.c

Go to the documentation of this file.
00001 
00002 /*  $Id: appletprioritydiskloop.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /* copyright 1991-96 UserLand Software, Inc. All Rights Reserved.*/
00005 
00006 
00007 #include "appletdefs.h"
00008 #include "appletfiles.h"
00009 #include "appletfilesinternal.h"
00010 #include "appletfolder.h"
00011 #include "appletprioritydiskloop.h"
00012 
00013 
00014 static tyfileloopcallback usercallback = nil;
00015 
00016 static short userfavoritevnum;
00017 
00018 static short passnum;
00019 
00020 
00021 
00022 static boolean priorityvisit (bigstring fname, tyfileinfo *info, long refcon) {
00023     
00024     boolean flslow = (*info).flhardwarelock || (*info).flremotevolume;
00025     boolean flfave = (*info).vnum == userfavoritevnum;
00026     
00027     switch (passnum) {
00028         
00029         case 0:
00030             if (!flfave) /*only interested in the favorite disk on pass 0*/
00031                 return (true);
00032                 
00033             if (flslow) /*we're going to ignore the favorite, it's a slow disk*/
00034                 return (true);
00035                 
00036             break;
00037         
00038         case 1: 
00039             if (flfave) /*already visited in pass 0*/
00040                 return (true);
00041                 
00042             if (flslow) /*save for pass 2*/
00043                 return (true);
00044                 
00045             break;
00046             
00047         case 2: 
00048             if (flfave) /*already visited in pass 0*/
00049                 return (true);
00050                 
00051             if (!flslow) /*already visited in pass 1*/
00052                 return (true);
00053                 
00054             break;
00055         } /*switch*/
00056     
00057     return ((*usercallback) (fname, info, refcon));
00058     } /*priorityvisit*/
00059     
00060 
00061 boolean prioritydiskloop (tyfileloopcallback callback, long refcon, short vnumfavorite) {
00062     
00063     /*
00064     same as diskloop, except we process the volumes 
00065     according to a sensible priority scheme.
00066     
00067     if vnumfavorite is non-zero, we look on that
00068     volume first.
00069     
00070     then we look on all fast volumes except the
00071     favorite one.
00072     
00073     finally we look at all slow volumes, ones that
00074     are remote, or hardware locked (probably CD's).
00075     
00076     note: these can't be nested because the callback 
00077     is stored in a static, it's not stacked.
00078     */
00079     
00080     short firstpassnum;
00081     
00082     usercallback = callback;
00083     
00084     userfavoritevnum = vnumfavorite;
00085     
00086     if (vnumfavorite == 0)
00087         firstpassnum = 1;
00088     else
00089         firstpassnum = 0;
00090     
00091     for (passnum = firstpassnum; passnum <= 2; passnum++) {
00092     
00093         if (!diskloop (&priorityvisit, refcon))
00094             return (false);
00095         } /*for*/
00096     
00097     return (true);
00098     } /*prioritydiskloop*/
00099     
00100 

Generated on Wed May 31 18:19:43 2006 for frontierkernel 10.1.10a by  doxygen 1.4.6