summaryrefslogtreecommitdiff
path: root/support/latexindent/LatexIndent/UTF8CmdLineArgsFileOperation.pm
diff options
context:
space:
mode:
Diffstat (limited to 'support/latexindent/LatexIndent/UTF8CmdLineArgsFileOperation.pm')
-rw-r--r--support/latexindent/LatexIndent/UTF8CmdLineArgsFileOperation.pm23
1 files changed, 15 insertions, 8 deletions
diff --git a/support/latexindent/LatexIndent/UTF8CmdLineArgsFileOperation.pm b/support/latexindent/LatexIndent/UTF8CmdLineArgsFileOperation.pm
index a2ba0b1d2f..45a2b6f538 100644
--- a/support/latexindent/LatexIndent/UTF8CmdLineArgsFileOperation.pm
+++ b/support/latexindent/LatexIndent/UTF8CmdLineArgsFileOperation.pm
@@ -66,12 +66,20 @@ sub open_with_encode {
require Win32::Unicode::File;
Win32::Unicode::File->import;
$fh = Win32::Unicode::File->new;
- open $fh, $mode, $filename or die "Can't open file: $!";
- return $fh;
+ if ( open $fh, $mode, $filename ) {
+ return $fh;
+ }
+ else {
+ return undef;
+ }
}
else {
- open( $fh, $mode, $filename ) or die "Can't open file: $!";
- return $fh;
+ if ( open( $fh, $mode, $filename ) ) {
+ return $fh;
+ }
+ else {
+ return undef;
+ }
}
}
@@ -79,7 +87,7 @@ sub read_yaml_with_encode {
use YAML::Tiny;
my $filename = shift;
- my $fh = open_with_encode( '<:encoding(UTF-8)', $filename ) or die $!;
+ my $fh = open_with_encode( '<:encoding(UTF-8)', $filename ) or return undef;
my $yaml_string = join( "", <$fh> );
return YAML::Tiny->read_string($yaml_string);
}
@@ -105,14 +113,13 @@ sub mkdir_with_encode {
require Win32::Unicode::Dir;
Win32::Unicode::Dir->import(qw(mkdirW));
- mkdirW($path) or die "Cannot create directory $path: $!";
+ mkdirW($path);
}
else {
require File::Path;
File::Path->import(qw(make_path));
- my $created = make_path($path);
- die "Cannot create directory $path" unless $created;
+ make_path($path);
}
}