appletfiledelete.c

Go to the documentation of this file.
00001 
00002 /*  $Id: appletfiledelete.c 355 2005-01-11 22:48:55Z andreradke $    */
00003 
00004 /* copyright 1991-96 UserLand Software, Inc. All Rights Reserved.*/
00005 
00006 
00007 #include "appletfiles.h"
00008 #include "appletfilesinternal.h"
00009 #include "appletfolder.h"
00010 #include "appletfiledelete.h"
00011 
00012 
00013 
00014 boolean filedeletevisit (bigstring bsitem, tyfileinfo *info, long refcon) {
00015     
00016     FSSpec fs;
00017     
00018     if (stringlength (fs.name) == 0) /*defensive driving -- if you turn this off -- it could delete C source code in the program you're testing*/
00019         return (false);
00020     
00021     filemakespec ((*info).vnum, (*info).dirid, bsitem, &fs);
00022     
00023     return (filedelete (&fs));
00024     } /*filedeletevisit*/
00025 
00026 
00027 boolean filedelete (ptrfilespec pfs) {
00028     
00029     OSErr ec;
00030     
00031     ec = FSpDelete (pfs);
00032     
00033     if (ec == fBsyErr) { /*could be a folder with items in it*/
00034         
00035         tyfileinfo info;
00036         
00037         filegetinfo (pfs, &info);
00038         
00039         if (!info.flfolder) /*not a folder, it's an error*/
00040             goto error;
00041             
00042         if (!folderloop (pfs, true, &filedeletevisit, 0))
00043             return (false);
00044             
00045         ec = FSpDelete (pfs); /*delete the now-empty folder*/
00046         }
00047         
00048     if (ec == noErr)
00049         return (true);
00050     
00051     error:
00052     
00053     fileerror (pfs, ec);
00054     
00055     return (false);
00056     } /*filedelete*/
00057     
00058     

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