MacOSX-File

 view release on metacpan or  search on metacpan

bin/psync  view on Meta::CPAN


exit;
sub do_log{
    print shift, "\n";
}

sub sig2txt{
    return sprintf("0x%08x,0x%08x",unpack("N2",shift));
}

sub addsig{
    my ($path, $mode,$uid,$gid,$size,$atime,$mtime, $action) = @_;
    my $sig  = pack("N2", (S_ISREG($mode) ? $size : 0), $mtime);
    tied %Attribs or $Attribs{$path} = pack("N4", $mode, $uid, $gid, $atime);
    if ($opt_v > 3 and $action > 0){
	do_log qq(was: ) . sig2txt($Signature{$path});
	do_log qq(now: ) . sig2txt($sig);
    }
    if ($Signature{$path} eq $sig){
	$opt_f or $action = 0;	   # same file
    }else{

bin/psync  view on Meta::CPAN

# we implement our own traversal routine

sub scantree {
    my ($root, $path, $action) = @_;
    if ($opt_v){
	$ScanCount % 8192 == 0 and  printf "\n%10d:", $ScanCount;
	$ScanCount % 128  == 0 and  print  ".";
	$ScanCount++;
    }
    if ($path =~ $IgnorePat){
	addsig($path, 0, 0, 0, 0, 0, 0, $Del_Ignored);
	return;
    }
    $action > 0 and $Root{$path} = $root;
    my $fpath = $root . $path;
    my ($dev, $mode, $nlink, $uid, $gid, $size, $atime, $mtime) =
	(lstat($fpath))[0,2,3,4,5,7,8,9] or warn "can't stat $fpath";

    addsig($path, $mode, $uid, $gid, $size, $atime, $mtime, $action);

    if (-d _){
	$dev != $Topdev and return;
	opendir my $d, $fpath or warn "$fpath:$!";
	# see ._* is avoided
	my @f = grep !/^\.(?:\.?$|_)/o, readdir $d;
	closedir $d;
	for my $f (@f){
	    my $spath = "$path/$f";
	    if ($IgnoreFiles{$f}){
		addsig($spath, $mode, $uid, $gid, $size, $mtime, $atime,
		       $Del_IgFiles) unless $f eq $Psync_DB;
	    }else{
		scantree($root, $spath, $action);
	    }
	}
    }
}

sub help{
    print <<"EOT";



( run in 0.543 second using v1.01-cache-2.11-cpan-71847e10f99 )