Project/Real_code/gnu/coreutils-5.0/src/du.c
static int
du_files (char **files, int ftw_flags)
{
  int fail = 0;
  int i;
  for (i = 0; files[i]; i++)
    {
      char *file = files[i];
      char *orig = file;
      int err;
      arg_length = 0;

      if (!print_totals)
	hash_clear (htab);

      /* When dereferencing only command line arguments, we're using
	 nftw's FTW_PHYS flag, so a symlink-to-directory specified on
	 the command line wouldn't normally be dereferenced.  To work
	 around that, we incur the overhead of appending `/.' (or `.')
	 now, and later removing it each time we output the name of
	 a derived file or directory name.  */
      if (opt_dereference_arguments && is_symlink_to_dir (file))
	{
	  size_t len = strlen (file);
	  /* Append `/.', but if there's already a trailing slash,
	     append only the `.'.  */
	  char const *suffix = (file[len - 1] == '/' ? "." : "/.");
	  char *new_file;
	  suffix_length = strlen (suffix);
	  new_file = xmalloc (len + suffix_length + 1);
	  memcpy (mempcpy (new_file, file, len), suffix, suffix_length + 1);
	  arg_length = len;
	  file = new_file;
	}

      err = nftw (file, process_file, MAX_N_DESCRIPTORS, ftw_flags);
      if (err)
	error (0, errno, "%s", quote (orig));
      fail |= err;

      if (arg_length)
	free (file);
    }

  if (print_totals)
    print_size (tot_size, _("total"));

  return fail;
}
/* Recursively print the sizes of the directories (and, if selected, files)
   named in FILES, the last entry of which is NULL.
   FTW_FLAGS controls how nftw works.
   Return nonzero upon error.  */
Recursively print the sizes of the directories (and, if selected, files)
named in FILES, the last entry of which is NULL.
FTW_FLAGS controls how nftw works.
Return nonzero upon error.
Recursively print the sizes of the directories ( and if selected files ) named in FILES the last entry of which is NULL . FTW_FLAGS controls how nftw works . Return nonzero upon error .
static int
du_files (char **files, int ftw_flags)
{
  int fail = 0;
  int i;
  for (i = 0; files[i]; i++)
    {
      char *file = files[i];
      char *orig = file;
      int err;
      arg_length = 0;
      if (!print_totals)
	hash_clear (htab);
      if (opt_dereference_arguments && is_symlink_to_dir (file))
	{
	  size_t len = strlen (file);
	  char const *suffix = (file[len - 1] == '/' ? "." : "/.");
	  char *new_file;
	  suffix_length = strlen (suffix);
	  new_file = xmalloc (len + suffix_length + 1);
	  memcpy (mempcpy (new_file, file, len), suffix, suffix_length + 1);
	  arg_length = len;
	  file = new_file;
	}
      err = nftw (file, process_file, MAX_N_DESCRIPTORS, ftw_flags);
      if (err)
	error (0, errno, "%s", quote (orig));
      fail |= err;
      if (arg_length)
	free (file);
    }
  if (print_totals)
    print_size (tot_size, _("total"));
  return fail;
}
static int du_files ( char * * files , int ftw_flags ) { int fail = 0 ; int i ; for ( i = 0 ; files [ i ] ; i ++ ) { char * file = files [ i ] ; char * orig = file ; int err ; arg_length = 0 ; if ( ! print_totals ) hash_clear ( htab ) ; if ( opt_dereference_arguments && is_symlink_to_dir ( file ) ) { size_t len = strlen ( file ) ; char const * suffix = ( file [ len - 1 ] == ' ' ? " " : " " ) ; char * new_file ; suffix_length = strlen ( suffix ) ; new_file = xmalloc ( len + suffix_length + 1 ) ; memcpy ( mempcpy ( new_file , file , len ) , suffix , suffix_length + 1 ) ; arg_length = len ; file = new_file ; } err = nftw ( file , process_file , MAX_N_DESCRIPTORS , ftw_flags ) ; if ( err ) error ( 0 , errno , " " , quote ( orig ) ) ; fail |= err ; if ( arg_length ) free ( file ) ; } if ( print_totals ) print_size ( tot_size , _ ( " " ) ) ; return fail ; }
Recursively print the sizes of the directories (and, if selected, files)
named in FILES, the last entry of which is NULL.
Recursively print the sizes of the directories ( and if selected files ) named in FILES the last entry of which is NULL .
/* When dereferencing only command line arguments, we're using
	 nftw's FTW_PHYS flag, so a symlink-to-directory specified on
	 the command line wouldn't normally be dereferenced.  To work
	 around that, we incur the overhead of appending `/.' (or `.')
	 now, and later removing it each time we output the name of
	 a derived file or directory name.  */ /* Append `/.', but if there's already a trailing slash,
	     append only the `.'.  */