Do not move symlinks when saving a map, overwrite target instead

If the user is editing a symlink to a target instead of a real file,
chances are high they want the symlink to stay in place.

Precondition:

  some.map -> /path/to/elsewhere.map

After save (before):

  some.bak -> /path/to/elsewhere.map
  some.map (real file)

After save (after):

  some.map -> /path/to/elsewhere.map

Closes #107.
This commit is contained in:
Walter Doekes
2022-08-27 16:03:40 +02:00
parent f61e0dcb67
commit dd81a7f0d7
3 changed files with 32 additions and 15 deletions

View File

@@ -175,13 +175,10 @@ bool Preferences_Save( PreferenceDictionary& preferences, const char* filename )
bool Preferences_Save_Safe( PreferenceDictionary& preferences, const char* filename ){
const auto tmpName = StringOutputStream()( filename, "TMP" );
return Preferences_Save( preferences, tmpName )
&& ( !file_exists( filename ) || file_remove( filename ) )
&& file_move( tmpName, filename );
return Preferences_Save( preferences, tmpName ) && file_move( tmpName, filename );
}
void LogConsole_importString( const char* string ){
g_Console_enableLogging = string_equal( string, "true" );
Sys_LogFile( g_Console_enableLogging );