App-rs
view release on metacpan or search on metacpan
BEGIN {
for my $c (qw/green cyan yellow magenta red/) {
no strict 'refs';
my $f = uc substr $c, 0, 1;
*$f = sub () { [$c] };
*{$f x 2} = sub () { ['bold', $c] };
}
}
sub set {
my ($f, $m) = @_;
# chown should be called before chmod to prevent setuid, setgid bit gets reset.
chown @$m{qw/uid gid/}, $f and chmod $m->{mode} & 07777, $f and utimensat($f, $m->{mtime}) or die "$f: $!";
}
sub equiv {
my ($p, $q) = @_;
no warnings 'uninitialized';
all { $p->{$_} eq $q->{$_} } qw/mode uid gid size mtime hl sl/;
}
sub elf {
open my $fh, '<', shift or die $!;
my $b;
read($fh, $b, 4) == 4 and $b eq "\x7fELF";
my $g = $cp->{root} . $q->{hl};
link $g, $f or die "unable to hard link $f to $g: $!";
} else {
wf($f, delete $q->{c});
set($f, $q);
}
} else {
# That's really nasty...
symlink my $g = $q->{sl}, $f or die "unable to symlink $f to $q->{sl}: $!.";
# symlink(7) explicitly says the permission of a symbolic link can't be changed(on Linux).
lchown($f, @$q{qw/uid gid/}) and utimensat($f, $q->{mtime}) or die "$f: $!";
}
# A new hash is required here and above since metadata varies for non-directory.
my $p = $db->{$_} = {%$q,
owner => $db->{$_}{owner}};
$p->{owner}{current} = $cp->{oid}, $p->{owner}{record}{$cp->{oid}} = $cp->{ts};
}
}
}
# merge two patch trees, the first one takes higher priority.
sub merge {
cwrite(fd, key, retlen);
LLAC(v);
} else {
TER;
}
}
}
cwrite(fd, NULL, 0);
bool
lchown(char *f, uid_t uid, gid_t gid)
POSTCALL:
RETVAL = !RETVAL;
bool
utimensat(char *f, int t)
CODE:
struct timespec times[2];
times[0].tv_nsec = UTIME_OMIT;
times[1].tv_sec = t, times[1].tv_nsec = 0;
RETVAL = !utimensat(AT_FDCWD, f, times, AT_SYMLINK_NOFOLLOW);
( run in 1.943 second using v1.01-cache-2.11-cpan-71847e10f99 )