Teach configure_file to handle directory names
This commit teaches configure_file how to handle directories for input and output. It is an error if the input is a directory. If the output is a directory we put the configured copy of the input file in it with the same name. See issue #9537.