summaryrefslogtreecommitdiff
path: root/support/latexindent/LatexIndent/LogFile.pm
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-07-15 03:00:53 +0000
committerNorbert Preining <norbert@preining.info>2023-07-15 03:00:53 +0000
commitf506889527fff6570e2878d55abbacf7227f2b3e (patch)
treecd24fedd1e37c61b098b38f95487b69d29e37397 /support/latexindent/LatexIndent/LogFile.pm
parentd4f9602cb865c2132ad3893fdb906be0f87f4d06 (diff)
CTAN sync 202307150300
Diffstat (limited to 'support/latexindent/LatexIndent/LogFile.pm')
-rw-r--r--support/latexindent/LatexIndent/LogFile.pm18
1 files changed, 13 insertions, 5 deletions
diff --git a/support/latexindent/LatexIndent/LogFile.pm b/support/latexindent/LatexIndent/LogFile.pm
index 5847ca42f4..4e9064c937 100644
--- a/support/latexindent/LatexIndent/LogFile.pm
+++ b/support/latexindent/LatexIndent/LogFile.pm
@@ -19,6 +19,7 @@ use strict;
use warnings;
use FindBin;
use File::Basename; # to get the filename and directory path
+use File::Path qw(make_path);
use Exporter qw/import/;
use LatexIndent::Switches qw/%switches/;
use LatexIndent::Version qw/$versionNumber $versionDate/;
@@ -129,12 +130,18 @@ ENDQUOTE
# cruft directory
${$self}{cruftDirectory} = $switches{cruftDirectory} || ( dirname ${$self}{fileName} );
- # if cruft directory does not exist
+ my $cruftDirectoryCreation = 0;
+
+ # if cruft directory does not exist, create it
if ( !( -d ${$self}{cruftDirectory} ) ) {
- $logger->fatal( "*Could not find directory " . decode( "utf-8", ${$self}{cruftDirectory} ) );
- $logger->fatal("Exiting, no indentation done.");
- $self->output_logfile();
- exit(6);
+ eval { make_path( ${$self}{cruftDirectory} ) };
+ if ($@) {
+ $logger->fatal( "*Could not create cruft directory " . decode( "utf-8", ${$self}{cruftDirectory} ) );
+ $logger->fatal("Exiting, no indentation done.");
+ $self->output_logfile();
+ exit(6);
+ }
+ $cruftDirectoryCreation = 1;
}
my $logfileName = ( $switches{cruftDirectory} ? ${$self}{cruftDirectory} . "/" : '' )
@@ -247,6 +254,7 @@ ENDQUOTE
$logger->info("*Directory for backup files and $logfileName:");
$logger->info( $switches{cruftDirectory} ? decode( "utf-8", ${$self}{cruftDirectory} ) : ${$self}{cruftDirectory} );
+ $logger->info("cruft directory creation: ${$self}{cruftDirectory}") if $cruftDirectoryCreation;
# output location of modules
if ( $FindBin::Script eq 'latexindent.pl' or ( $FindBin::Script eq 'latexindent.exe' and $switches{trace} ) ) {