From: Thomas Debesse Date: Sun, 19 Jun 2022 19:17:32 +0000 (+0200) Subject: radiant: restore original backup behaviour on Windows, ref 4d38a666 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0976a3a3ed8d0574c639fc4ee033e4c2da2b93f3;p=xonotic%2Fnetradiant.git radiant: restore original backup behaviour on Windows, ref 4d38a666 Restore original backup behaviour on Windows as NT symlinks are not handled yet, see 4d38a666f972e7cbc2156865a2c99ecf2192c467. --- diff --git a/radiant/referencecache.cpp b/radiant/referencecache.cpp index cf5abe0c..88f3fb3a 100644 --- a/radiant/referencecache.cpp +++ b/radiant/referencecache.cpp @@ -124,7 +124,14 @@ bool file_saveBackup( const char* path ){ StringOutputStream backup( 256 ); backup << StringRange( path, path_get_extension( path ) ) << "bak"; +#if GDEF_OS_WINDOWS + // NT symlinks are not supported yet. + return ( !file_exists( backup.c_str() ) || file_remove( backup.c_str() ) ) // remove backup + && file_move( path, backup.c_str() ); // rename current to backup +#else + // POSIX symlinks are supported. return file_move( path, backup.c_str() ); // rename current to backup +#endif } globalErrorStream() << "map path is not writeable: " << makeQuoted( path ) << "\n"; @@ -136,6 +143,11 @@ bool MapResource_save( const MapFormat& format, scene::Node& root, const char* p fullpath << path << name; if ( path_is_absolute( fullpath.c_str() ) ) { +#if GDEF_OS_WINDOWS + // NT symlinks are not supported yet. + if ( !file_exists( fullpath.c_str() ) || file_saveBackup( fullpath.c_str() ) ) { +#else + // POSIX symlinks are supported. /* We don't want a backup + rename operation if the .map file is * a symlink. Otherwise we'll break the user's careful symlink setup. * Just overwrite the original file. Assume the user has versioning. */ @@ -151,6 +163,7 @@ bool MapResource_save( const MapFormat& format, scene::Node& root, const char* p } if ( !make_backup || file_saveBackup( fullpath.c_str() ) ) { +#endif return MapResource_saveFile( format, root, Map_Traverse, fullpath.c_str() ); }