In copyfile_open(), validate and normalize the file permissions and mode, and rewrite the file / directory creation logic to avoid opening an existing file twice. Improve error messages.
In copyfile_open(), validate and normalize the file permissions and mode, and rewrite the file / directory creation logic to avoid opening an existing file twice.
Improve error messages.

petterreinholdtsen/tsdfx,abdulrahmanazab/tsdfx,abdulrahmanazab/tsdfx,dag-erling/tsdfx,petterreinholdtsen/tsdfx,dag-erling/tsdfx,dag-erling/tsdfx,petterreinholdtsen/tsdfx