28487ef3097032de4eb607cc5398a7a1592af7fe
Remove a directory and all its contents.
Copyright (C) 1992 Ian Lance Taylor
This file is part of the Taylor UUCP package.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
static int isremove_dir
P((const char *, const struct stat
*, int));
/* Keep a list of directories to be removed. */
static struct sdirlist
*qSdirlist
;
/* Remove a directory and all files in it. */
if (ftw ((char *) zdir
, isremove_dir
, 5) != 0)
ulog (LOG_ERROR
, "ftw: %s", strerror (errno
));
if (rmdir (q
->zdir
) != 0)
ulog (LOG_ERROR
, "rmdir (%s): %s", q
->zdir
, strerror (errno
));
/* Remove a file in a directory. */
isremove_dir (zfile
, qstat
, iflag
)
const struct stat
*qstat
;
if (iflag
== FTW_D
|| iflag
== FTW_DNR
)
q
= (struct sdirlist
*) xmalloc (sizeof (struct sdirlist
));
q
->zdir
= zbufcpy (zfile
);
ulog (LOG_ERROR
, "remove (%s): %s", zfile
, strerror (errno
));