Safer config saving (PR #6987)
Fixes issue #3165
Save configuration profiles and gesture maps as an atomic operation
Instead of directly writing the file, a temporary file is created and moved to the final location. This prevents corrupt configuration files being written.
Added a `fileUtils` module with just a `FaultTolerantFile` context manager for now to facilitate this pattern.