CTKlib
view release on metacpan or search on metacpan
lib/CTK/Command.pm view on Meta::CPAN
return 0 unless length($src) && -e $src;
return 0 unless length($file);
return 0 unless length($dst);
my $ctk = CTK->new(plugins => "file");
unless ($ctk->status) {
die $ctk->error;
}
$ctk->fsplit(
-dirsrc => $src,
-dirdst => $dst,
-file => $file,
-lines => $lines,
-format => $format,
) or do {
die $ctk->error if $ctk->error;
die("File not found");
};
return 1;
}
sub fjoin {
my $src = shift(@ARGV) // "";
my $mask = shift(@ARGV) // "";
my $dst = shift(@ARGV) // "";
my $file = shift(@ARGV) // "";
return 0 unless length($src) && -e $src;
my $ctk = CTK->new(plugins => "file");
unless ($ctk->status) {
die $ctk->error;
}
$ctk->fjoin(
-dirsrc => $src,
-dirdst => $dst,
-mask => $mask,
-fileout => $file,
) or do {
die $ctk->error if $ctk->error;
die("File not found");
};
return 1;
}
sub crlf {
_expand_wildcards();
find({ wanted => sub {
return if -d;
return if -z _;
return unless -w _;
return unless -r _;
return unless -T _;
my $orig = $_;
my $dir = $File::Find::dir;
my $file = File::Spec->catfile($dir, $orig);
my (@fromstat) = stat $orig;
print "Normalizing the linefeeds in file $file... ";
file_lf_normalize($orig) or do {
print STDERR "Can't create file $orig: $!\n";
return
};
my $perm = $fromstat[2] || 0;
$perm &= 07777;
eval { chmod $perm, $orig; };
if ($@) {
print STDERR $@, "\n"
} else {
print "ok\n";
}
}}, @ARGV);
}
1;
__END__
( run in 1.058 second using v1.01-cache-2.11-cpan-39bf76dae61 )