From 362c431cfd8089693b7d836dd1dd2044b6a1ce45 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 3 May 2002 18:53:52 +0000 Subject: [PATCH] Create directories as needed. --- misc/ChangeLog | 2 ++ misc/autopoint.in | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/misc/ChangeLog b/misc/ChangeLog index db7e38cae..219829be0 100644 --- a/misc/ChangeLog +++ b/misc/ChangeLog @@ -2,6 +2,8 @@ * autopoint.in: Unset all other environment variables which influence cvs. Pass -d $CVSROOT explicitly. + (func_mkdir_for): New function. + (func_copy): Call it. 2002-05-01 Bruno Haible diff --git a/misc/autopoint.in b/misc/autopoint.in index 57735358e..a3d5aef4a 100644 --- a/misc/autopoint.in +++ b/misc/autopoint.in @@ -308,6 +308,20 @@ if test -z "$force"; then fi fi +# func_mkdir_for to +# ensures the directory that would the given file exists. +# 'to' is a relative pathname, relative to the current directory. +func_mkdir_for () +{ + base=`echo "$1" | sed -e 's,/[^/]*$,,'` + if test "X$base" != "X$1" && test -n "$base"; then + func_mkdir_for "$base" + # Recompute base. It was clobbered by the recursive call. + base=`echo "$1" | sed -e 's,/[^/]*$,,'` + test -d "$base" || { echo "Creating directory $base"; mkdir "$base"; } + fi +} + # func_copy from to # copies a file. # 'from' is a relative pathname, relative to the current directory. @@ -315,6 +329,7 @@ fi func_copy () { if $doit; then + func_mkdir_for "$2" rm -f "$2" echo "Copying file $2" cp "$1" "$2" -- 2.47.2