File-Rsync

 view release on metacpan or  search on metacpan

Rsync.pm  view on Meta::CPAN

passed first.
They should have the proper single or double hyphen prefixes and the elements
should be split up the way you want them passed to exec.
The purpose of this option is to allow the use of arbitrary options added by
patches, and/or to allow the use of new options in rsync without needing an
imediate update to the module in addtition to I<rsync(1)> itself.

=cut

sub new {
   my $class = shift;

   # seed the options hash, booleans, scalars, excludes, source, dest, data,
   # status, stderr/stdout storage for last exec
   my $self = {
      # these are the boolean flags to rsync, all default off, including them
      # in the args list turns them on
      flag => {
         map { $_ => 0 }
            qw(8-bit-output acls append append-verify archive backup
            blocking-io checksum compress copy-dirlinks copy-links
            copy-unsafe-links crtimes cvs-exclude daemon del delay-updates
            delete delete-after delete-before delete-delay delete-during
            delete-excluded delete-missing-args devices dirs dry-run
            executability existing fake-super fileflags force force-change
            force-delete force-schange force-uchange from0 fuzzy group groups
            hard-links help hfs-compression ignore-errors ignore-existing
            ignore-missing-args ignore-non-existing ignore-times inc-recursive
            inplace ipv4 ipv6 keep-dirlinks links list-only msgs2stderr
            munge-links new-compress no-blocking-io no-detach no-devices
            no-dirs no-groups no-iconv no-implied-dirs no-inc-recursive
            no-links no-motd no-owner no-partial no-perms no-progress
            no-protect-args no-recursive no-relative no-specials no-super
            no-times no-whole-file numeric-ids old-compress old-dirs
            omit-dir-times omit-link-times owner partial perms preallocate
            progress protect-args protect-decmpfs prune-empty-dirs recursive
            relative remove-source-files safe-links size-only sparse specials
            stats super times update version whole-file xattrs)
      },
      # these have simple scalar args we cannot easily check
      # use 'string' so I don't forget and leave keyword scalar unqouted
      string => {
         map { $_ => '' }
            qw(address backup-dir block-size bwlimit checksum-seed chown
            compress-level config contimeout csum-length debug files-from
            groupmap iconv info log-file log-file-format log-format max-delete
            max-size min-size modify-window only-write-batch out-format outbuf
            partial-dir password-file port protocol read-batch rsh rsync-path
            skip-compress sockopts suffix temp-dir timeout usermap
            write-batch)
      },
      # these are not flags but counters, each time they appear it raises the
      # count, so we keep track and pass them the same number of times
      counter => {
         map { $_ => 0 }
            qw(human-readable itemize-changes one-file-system quiet verbose)
      },
      # these can be specified multiple times and are additive, the doc also
      # specifies that it is an ordered list so we must preserve that order
      list => {
         'chmod'         => [],
         'compare-dest'  => [],
         'copy-dest'     => [],
         'dparam'        => [],
         'exclude'       => [],
         'exclude-from'  => [],
         'filter'        => [],
         'include'       => [],
         'include-from'  => [],
         'link-dest'     => [],
         'literal'       => [],
         'remote-option' => [],
      },
      code => {    # input/output user functions
         'errfun' => undef,
         'outfun' => undef,
         # function to prvide --*-from=- data via pipe
         'infun' => undef,
      },
      _perlopts => {
         # the path name to the rsync binary (default is to use $PATH)
         'path-to-rsync' => 'rsync',
         # hostname of source, used if 'source' is an array reference
         'srchost' => '',
         # double-quote source and/or destination paths
         'quote-src' => 0,
         'quote-dst' => 0,
         # whether or not to print debug statements
         'moddebug' => 0,
      },
      # source host and/or path names
      'source' => '',
      # destination host and/or path
      'dest' => '',
      # return status from last exec
      '_status'     => 0,
      '_realstatus' => 0,
      # last rsync command-line executed
      '_lastcmd' => undef,
     # stderr from last exec in array format (messages from remote rsync proc)
      '_err' => 0,
      # stdout from last exec in array format (messages from local rsync proc)
      '_out' => 0,
      # this flag changes error checking in 'exec' when called by 'list'
      '_list_mode' => 0,
      # this array used to preserve arg order
      '_args' => [],
   };
   bless $self, $class;    # bless it first so defopts can find out the class
   if (@_) {
      &defopts($self, @_) or return;
   }
   return $self;
}

=head2 File::Rsync::defopts

    $obj->defopts(@options);

        or



( run in 0.242 second using v1.01-cache-2.11-cpan-2b0bae70ee8 )