diff --git a/bin/foamGetDict b/bin/foamGetDict
index 35ded94201..846cf62ec5 100755
--- a/bin/foamGetDict
+++ b/bin/foamGetDict
@@ -45,6 +45,7 @@ options:
-case
Alternative case directory, default is the cwd
-ext File extension
-cfg Same as '-e cfg' for '.cfg' files
+ -f | -force Force overwrite of existing files
-no-ext Files without extension
-target Target directory (default: system, or auto-detected)
-with-api=NUM Alternative api value for searching
@@ -86,7 +87,7 @@ projectApi="$FOAM_API"
#-------------------------------------------------------------------------------
searchExt=""
-unset targetDir
+unset targetDir optForce
while [ "$#" -gt 0 ]
do
@@ -113,6 +114,9 @@ do
-cfg)
searchExt="cfg"
;;
+ -f | -force)
+ optForce=true
+ ;;
-target)
[ "$#" -ge 2 ] || die "'$1' option requires an argument"
targetDir="$2"
@@ -221,12 +225,27 @@ findFiles()
}
-# Slightly dressed up version of 'cp -v'
+# Slightly dressed up version of 'cp -v' that does not clobber existing files
copyFile()
{
+ local targetFile="$2"
+
+ [ -d "$2" ] && targetFile="$targetFile/${1##*/}"
+
echo 1>&2
- echo "Copying $1 to $2" 1>&2
- \cp "$1" "$2"
+ if [ -f "$targetFile" ]
+ then
+ if [ "$optForce" = true ]
+ then
+ echo "Overwrite $1 to $2" 1>&2
+ \cp "$1" "$2"
+ else
+ echo "Skip copy $1 to $2" 1>&2
+ fi
+ else
+ echo "Copying $1 to $2" 1>&2
+ \cp "$1" "$2"
+ fi
echo 1>&2
}