Browse Source

* Subtitle::BASE->from_file : return undef on error

master
Alex 'AdUser' Z 6 years ago
parent
commit
7eac929532
  1. 6
      bin/ssa-retime
  2. 2
      lib/Subtitle/BASE.pm

6
bin/ssa-retime

@ -103,8 +103,10 @@ if ($mode eq 'framerate') {
} }
my $ssa = Subtitle::SSA->new(debug => !!$opts{loglevel}); my $ssa = Subtitle::SSA->new(debug => !!$opts{loglevel});
if ($ssa->from_file($opts{infile}) < 0) { unless ($ssa->from_file($opts{infile})) {
warn "Can't parse input file: $opts{infile}\n"; foreach my $line (@{ $ssa->{log} }) {
print $line, "\n";
}
exit 1; exit 1;
} }

2
lib/Subtitle/BASE.pm

@ -34,7 +34,7 @@ sub from_string {
sub from_file { sub from_file {
my ($self, $path) = @_; my ($self, $path) = @_;
open my $FH, '<', $path open my $FH, '<', $path
or return -1; or return $self->log(error => "can't open file: $path -- $!");
my @lines = <$FH>; my @lines = <$FH>;
close $FH; close $FH;
return unless @lines; # empty file? return unless @lines; # empty file?

Loading…
Cancel
Save