bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On second thought...


From: Brendan Byrd
Subject: On second thought...
Date: Thu, 02 Aug 2001 11:43:02 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.2) Gecko/20010628

  -d, --dirsonly          Only change the permissions of directories
  -D, --filesonly         Only change the permissions of files

Sorry, realized this would work better.  Everything is in the diff file.

--
Brendan Byrd (address@hidden)
System Administrator @ Mission Data
http://www.missiondata.com/

*** chmod-old.c Sun Nov 19 11:56:33 2000
--- chmod.c     Thu Aug  2 11:40:50 2001
***************
*** 15,21 ****
     along with this program; if not, write to the Free Software Foundation,
     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
! /* Written by David MacKenzie <address@hidden> */
  
  #include <config.h>
  #include <stdio.h>
--- 15,22 ----
     along with this program; if not, write to the Free Software Foundation,
     Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  
! /* Written by David MacKenzie <address@hidden>
!      -d/-D options by Brendan Byrd <address@hidden> */
  
  #include <config.h>
  #include <stdio.h>
***************
*** 53,58 ****
--- 54,71 ----
    V_off
  };
  
+ enum File_Dir
+ {
+   /* Include only files. */
+   FD_files,
+ 
+   /* Include only directories. */
+   FD_dirs,
+   
+   /* Include both files and directories. */
+   FD_all
+ };
+ 
  void strip_trailing_slashes ();
  
  static int change_dir_mode PARAMS ((const char *dir,
***************
*** 68,73 ****
--- 81,89 ----
  /* If nonzero, force silence (no error messages). */
  static int force_silent;
  
+ /* Change only the permissions of files and/or directories. */
+ static enum File_Dir files_dirs_only = FD_all;
+ 
  /* Level of verbosity.  */
  static enum Verbosity verbosity = V_off;
  
***************
*** 85,90 ****
--- 101,108 ----
  static struct option const long_options[] =
  {
    {"recursive", no_argument, 0, 'R'},
+   {"dirsonly", no_argument, 0, 'd'},
+   {"filesonly", no_argument, 0, 'D'},
    {"changes", no_argument, 0, 'c'},
    {"silent", no_argument, 0, 'f'},
    {"quiet", no_argument, 0, 'f'},
***************
*** 186,207 ****
      }
  #endif
  
!   newmode = mode_adjust (file_stats.st_mode, changes);
! 
!   fail = chmod (file, newmode);
!   saved_errno = errno;
! 
!   if (verbosity == V_high
!       || (verbosity == V_changes_only
!         && !fail && mode_changed (file, file_stats.st_mode)))
!     describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
! 
!   if (fail)
!     {
!       if (force_silent == 0)
!       error (0, saved_errno, _("changing permissions of %s"),
!              quote (file));
!       errors = 1;
      }
  
    if (recurse && S_ISDIR (file_stats.st_mode))
--- 204,229 ----
      }
  #endif
  
!   if ((files_dirs_only == FD_dirs && S_ISDIR (file_stats.st_mode))
!       || (files_dirs_only == FD_files && !(S_ISDIR (file_stats.st_mode))))
!     { 
!       newmode = mode_adjust (file_stats.st_mode, changes);
! 
!       fail = chmod (file, newmode);
!       saved_errno = errno;
! 
!       if (verbosity == V_high
!           || (verbosity == V_changes_only
!               && !fail && mode_changed (file, file_stats.st_mode)))
!         describe_change (file, newmode, (fail ? CH_FAILED : CH_SUCCEEDED));
! 
!       if (fail)
!         {
!           if (force_silent == 0)
!             error (0, saved_errno, _("changing permissions of %s"),
!                  quote (file));
!           errors = 1;
!         }
      }
  
    if (recurse && S_ISDIR (file_stats.st_mode))
***************
*** 278,283 ****
--- 300,307 ----
    -v, --verbose           output a diagnostic for every file processed\n\
        --reference=RFILE   use RFILE's mode instead of MODE values\n\
    -R, --recursive         change files and directories recursively\n\
+   -d, --dirsonly          Only change the permissions of directories\n\
+   -D, --filesonly         Only change the permissions of files\n\
        --help              display this help and exit\n\
        --version           output version information and exit\n\
  \n\
***************
*** 314,320 ****
      {
        thisind = optind ? optind : 1;
  
!       c = getopt_long (argc, argv, "RcfvrwxXstugoa,+-=", long_options, NULL);
        if (c == -1)
        break;
  
--- 338,344 ----
      {
        thisind = optind ? optind : 1;
  
!       c = getopt_long (argc, argv, "DRcdfvrwxXstugoa,+-=", long_options, 
NULL);
        if (c == -1)
        break;
  
***************
*** 354,359 ****
--- 378,389 ----
        case 'c':
          verbosity = V_changes_only;
          break;
+         case 'd':
+           files_dirs_only = FD_dirs;
+           break;
+         case 'D':
+           files_dirs_only = FD_files;
+           break;
        case 'f':
          force_silent = 1;
          break;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]