function.c (1e2f8412e0bd1ab80eae5c6fbcda5fcf139dce2c) | function.c (ed1a4621a2ae51371c8e4f181fcb4cdf80d92104) |
---|---|
1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Cimarron D. Taylor of the University of California, Berkeley. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 35 unchanged lines hidden (view full) --- 44#endif /* not lint */ 45 46#include <sys/param.h> 47#include <sys/ucred.h> 48#include <sys/stat.h> 49#include <sys/wait.h> 50#include <sys/mount.h> 51 | 1/*- 2 * Copyright (c) 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Cimarron D. Taylor of the University of California, Berkeley. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 35 unchanged lines hidden (view full) --- 44#endif /* not lint */ 45 46#include <sys/param.h> 47#include <sys/ucred.h> 48#include <sys/stat.h> 49#include <sys/wait.h> 50#include <sys/mount.h> 51 |
52#include <dirent.h> |
|
52#include <err.h> 53#include <errno.h> 54#include <fnmatch.h> 55#include <fts.h> 56#include <grp.h> 57#include <pwd.h> 58#include <stdio.h> 59#include <stdlib.h> --- 320 unchanged lines hidden (view full) --- 380 } 381 new->e_argv[cnt] = new->e_orig[cnt] = NULL; 382 383 *argvp = argv + 1; 384 return (new); 385} 386 387/* | 53#include <err.h> 54#include <errno.h> 55#include <fnmatch.h> 56#include <fts.h> 57#include <grp.h> 58#include <pwd.h> 59#include <stdio.h> 60#include <stdlib.h> --- 320 unchanged lines hidden (view full) --- 381 } 382 new->e_argv[cnt] = new->e_orig[cnt] = NULL; 383 384 *argvp = argv + 1; 385 return (new); 386} 387 388/* |
389 * -empty functions -- 390 * 391 * True if the file or directory is empty 392 */ 393int 394f_empty(plan, entry) 395 PLAN *plan; 396 FTSENT *entry; 397{ 398 if (S_ISREG(entry->fts_statp->st_mode) && entry->fts_statp->st_size == 0) 399 return (1); 400 if (S_ISDIR(entry->fts_statp->st_mode)) { 401 struct dirent *dp; 402 int empty; 403 DIR *dir; 404 405 empty = 1; 406 dir = opendir(entry->fts_accpath); 407 if (dir == NULL) 408 err(1, "%s", entry->fts_accpath); 409 for (dp = readdir(dir); dp; dp = readdir(dir)) 410 if (dp->d_name[0] != '.' || 411 (dp->d_name[1] != '\0' && 412 (dp->d_name[1] != '.' || dp->d_name[2] != '\0'))) { 413 empty = 0; 414 break; 415 } 416 closedir(dir); 417 return (empty); 418 } 419 return (0); 420} 421 422PLAN * 423c_empty() 424{ 425 ftsoptions &= ~FTS_NOSTAT; 426 427 return (palloc(N_EMPTY, f_empty)); 428} 429 430/* |
|
388 * -execdir utility [arg ... ] ; functions -- 389 * 390 * True if the executed utility returns a zero value as exit status. 391 * The end of the primary expression is delimited by a semicolon. If 392 * "{}" occurs anywhere, it gets replaced by the unqualified pathname. 393 * The current directory for the execution of utility is the same as 394 * the directory where the file lives. 395 */ --- 1081 unchanged lines hidden --- | 431 * -execdir utility [arg ... ] ; functions -- 432 * 433 * True if the executed utility returns a zero value as exit status. 434 * The end of the primary expression is delimited by a semicolon. If 435 * "{}" occurs anywhere, it gets replaced by the unqualified pathname. 436 * The current directory for the execution of utility is the same as 437 * the directory where the file lives. 438 */ --- 1081 unchanged lines hidden --- |