appletfilemodified.c

Go to the documentation of this file.
00001 
00002 /*  $Id: appletfilemodified.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /* copyright 1991-96 UserLand Software, Inc. All Rights Reserved.*/
00005 
00006 
00007 #include "appletmemory.h"
00008 #include "appletfolder.h"
00009 #include "appletfilesinternal.h"
00010 #include "appletfilemodified.h"
00011 
00012 
00013 boolean filegetmodified (ptrfilespec pfs, long *modified) {
00014     
00015     /*
00016     single entry-point to get a folder's modification date. need this
00017     to be absolutely as fast as possible.
00018     */
00019         
00020     CInfoPBRec pb;
00021     
00022     if (!getmacfileinfo (pfs, &pb))
00023         return (false);
00024         
00025     *modified = pb.dirInfo.ioDrMdDat;
00026     
00027     return (true);
00028     } /*filegetmodified*/
00029     
00030 
00031 static boolean setmodified (ptrfilespec pfs, long modified) {
00032 
00033     CInfoPBRec pb;
00034     
00035     if (!getmacfileinfo (pfs, &pb))
00036         return (false);
00037         
00038     pb.dirInfo.ioDrMdDat = modified;
00039     
00040     return (setmacfileinfo (pfs, &pb));
00041     } /*setmodified*/
00042 
00043 
00044 boolean filetouchparentfolder (ptrfilespec pfs) {
00045     
00046     /*
00047     set the modification date of the file's parent folder. this is 
00048     the protocol used by Clay Basket and the Finder to tell if the 
00049     contents of a folder needs to be refreshed.
00050     
00051     dmb 9/21/93: broke this out into it's own routine. when touching 
00052     the parent, the current time should always be used, even if the file's
00053     mod date is being set to something else. also, this needs to be 
00054     directly callable; renaming a file touches the parent, but doesn't 
00055     change the file's mod date.
00056     */
00057     
00058     FSSpec fsfolder;
00059     long timenow;
00060     
00061     GetDateTime ((unsigned long *) &timenow);
00062     
00063     filegetparentfolderspec (pfs, &fsfolder);
00064     
00065     return (setmodified (&fsfolder, timenow));
00066     } /*filetouchparentfolder*/
00067 
00068 
00069 boolean filesetmodified (ptrfilespec pfs, long modified) {
00070 
00071     /*
00072     set the modification date of the file. if it's 0, 
00073     we use the current time.
00074     
00075     also set the modification date of its parent folder.
00076     */
00077     
00078     if (modified == 0)
00079         GetDateTime ((unsigned long *) &modified);
00080     
00081     if (!setmodified (pfs, modified))
00082         return (false);
00083     
00084     filetouchparentfolder (pfs);
00085     
00086     return (true);
00087     } /*filesetmodified*/
00088 
00089 
00090 boolean filetouchallparentfolders (ptrfilespec pfs) {
00091     
00092     tyfilespec fs = *pfs, fsparent;
00093     long now;
00094     
00095     GetDateTime ((unsigned long *) &now);
00096     
00097     while (true) {
00098         
00099         if (!filegetparentfolderspec (&fs, &fsparent))
00100             return (true);
00101         
00102         if (!setmodified (&fsparent, now))
00103             return (false);
00104         
00105         fs = fsparent;
00106         } /*while*/
00107     } /*filetouchallparentfolders*/
00108     
00109     

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