an error.
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (unlink(fileName) < 0) {
- perror(fileName);
+ perrorMsg("%s", fileName);
return (FALSE);
}
return (TRUE);
{
if (recursiveFlag == FALSE) {
errno = EISDIR;
- perror(fileName);
+ perrorMsg("%s", fileName);
return (FALSE);
}
if (rmdir(fileName) < 0) {
- perror(fileName);
+ perrorMsg("%s", fileName);
return (FALSE);
}
return (TRUE);
extern int rm_main(int argc, char **argv)
{
+ int status = EXIT_SUCCESS;
int stopIt=FALSE;
struct stat statbuf;
} else {
if (recursiveAction(srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction, NULL) == FALSE) {
- return EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
}
}
- return EXIT_SUCCESS;
+ return status;
}
static int fileAction(const char *fileName, struct stat *statbuf, void* junk)
{
if (unlink(fileName) < 0) {
- perror(fileName);
+ perrorMsg("%s", fileName);
return (FALSE);
}
return (TRUE);
{
if (recursiveFlag == FALSE) {
errno = EISDIR;
- perror(fileName);
+ perrorMsg("%s", fileName);
return (FALSE);
}
if (rmdir(fileName) < 0) {
- perror(fileName);
+ perrorMsg("%s", fileName);
return (FALSE);
}
return (TRUE);
extern int rm_main(int argc, char **argv)
{
+ int status = EXIT_SUCCESS;
int stopIt=FALSE;
struct stat statbuf;
} else {
if (recursiveAction(srcName, recursiveFlag, FALSE,
TRUE, fileAction, dirAction, NULL) == FALSE) {
- return EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
}
}
- return EXIT_SUCCESS;
+ return status;
}
"status=%d followLinks=%d TRUE=%d\n",
status, followLinks, TRUE);
#endif
- perror(fileName);
+ perrorMsg("%s", fileName);
return FALSE;
}
dir = opendir(fileName);
if (!dir) {
- perror(fileName);
+ perrorMsg("%s", fileName);
return FALSE;
}
if (dirAction != NULL && depthFirst == FALSE) {
status = dirAction(fileName, &statbuf, userData);
if (status == FALSE) {
- perror(fileName);
+ perrorMsg("%s", fileName);
return FALSE;
}
}
}
status = closedir(dir);
if (status < 0) {
- perror(fileName);
+ perrorMsg("%s", fileName);
return FALSE;
}
if (dirAction != NULL && depthFirst == TRUE) {
status = dirAction(fileName, &statbuf, userData);
if (status == FALSE) {
- perror(fileName);
+ perrorMsg("%s", fileName);
return FALSE;
}
}