This PR fixes the problem with handling of irregular file names described in #17612
It also defines a helper function CanWriteFile that is used by dumptxoutset and dumpwallet.
This function checks for:
- file name existence (if only a dir-path was given the execution stops with a corresponding JSON error)
- file name validity
- file name portability between POSIX and Windows
- write permissions
- file existence (if a file already exists the dump* operation stops, like it was done in previous versions)
The already existing JSON return objects and their messages have been preserved to prevent failing of tests and/or 3rd party tools whose parsers maybe rely on them.
Two tests have been added: in rpc_tests.cpp and test/functional/rpc_dumptxoutset.py
Closes: #17612