(trunk libT) #3172 "transmission overwrites settings.json" -- fixed with kklimonda's patch for 2.00

This commit is contained in:
Charles Kerr 2010-04-29 18:56:34 +00:00
parent 8104f4a960
commit 31f4d24004
1 changed files with 11 additions and 4 deletions

View File

@ -11,11 +11,12 @@
*/
#include <assert.h>
#include <ctype.h> /* isdigit */
#include <ctype.h> /* isdigit() */
#include <errno.h>
#include <math.h> /* fabs */
#include <limits.h> /* PATH_MAX */
#include <math.h> /* fabs() */
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h> /* realpath() */
#include <string.h>
#include <sys/types.h> /* stat() */
@ -23,7 +24,7 @@
#include <locale.h>
#include <unistd.h> /* stat(), close() */
#include <event.h> /* evbuffer */
#include <event.h> /* struct evbuffer */
#include "ConvertUTF.h"
@ -1620,6 +1621,12 @@ tr_bencToFile( const tr_benc * top, tr_fmt_mode mode, const char * filename )
char * tmp;
int fd;
int err = 0;
char buf[PATH_MAX];
/* follow symlinks to find the "real" file, to make sure the temporary
* we build with mkstemp() is created on the right partition */
if( realpath( filename, buf ) != NULL )
filename = buf;
/* if the file already exists, try to move it out of the way & keep it as a backup */
tmp = tr_strdup_printf( "%s.tmp.XXXXXX", filename );