ussg

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 90d6e8c40e469518393d9c45b4cd865869b012e7
parent d0b430a78f98b4a7192bc6395e715af57d2c21ac
Author: Ellenor Bjornsdottir <ellenor@umbrellix.net>
Date:   Mon, 12 Sep 2022 12:31:08 +0000

Automatically create directories missing to contain the output file

Diffstat:
Mussg-page | 13+++++++++++++
1 file changed, 13 insertions(+), 0 deletions(-)

diff --git a/ussg-page b/ussg-page @@ -287,6 +287,19 @@ if {[llength $arg] == 2} { puts stderr [format "Error: output file \'%s\' already exists. You asked me not to scribble on it, so I am not scribbling on it." $outputfile] exit 73 } + set outputdir [file dirname $outputfile] + set outputmkdir [list file mkdir] + if {![file exists $outputdir]} { + while {![file exists $outputdir]} { + lappend outputmkdir $outputdir + set outputdir [file dirname $outputdir] + } + } + if {[catch $outputmkdir mkdirerr]} { + puts stderr [format "Error: directories to contain output file \'%s\' could not be created. \[file mkdir\] reports:" $::outputfile] + puts stderr $mkdirerr + exit 73 + } if {[catch {open [set ::tmpoutputfile [picktmpfilename [set outputfile [file normalize $outputfile]]]] w} provoutputfd]} { puts stderr [format "Error: temporary output file \'%s\' could not be opened for writing. \[open\] reports:" $::tmpoutputfile] puts stderr $provoutputfd