simplify_static_dir/lib/Directory/Simplify/Instruction/CopyTimestamp.pm

34 lines
665 B
Perl

package Directory::Simplify::Instruction::CopyTimestamp;
use strict;
use warnings;
use overload '""' => 'as_string';
# :squash-remove-start:
require Directory::Simplify::Utils;
# :squash-remove-end:
sub new {
my ($class, %args) = @_;
return bless {
%args,
}, $class;
}
sub run {
my $self = shift;
# preserve older time stamp
utime $self->{source}->{atime}, $self->{source}->{mtime}, $self->{target}->{name};
return;
}
sub bytes_freed {
return 0;
}
sub as_string {
my $self = shift;
return sprintf 'touch -r %s %s', Directory::Simplify::Utils::shell_quote($self->{source}->{name}, $self->{target}->{name});
}
1;