nonlib: Use tmp file when generating snapshot.

This commit is contained in:
Jonathan Moore Liles 2013-03-18 17:21:37 -07:00
parent 14099b7cfc
commit 7d5a0e13f6
1 changed files with 9 additions and 1 deletions

View File

@ -568,13 +568,21 @@ Loggable::snapshot ( const char *name )
{ {
FILE *fp; FILE *fp;
if ( ! ( fp = fopen( name, "w" ) )) char *tmpname;
asprintf( &tmpname, ".#%s", name );
if ( ! ( fp = fopen( tmpname, "w" ) ))
return false; return false;
bool r = snapshot( fp ); bool r = snapshot( fp );
fclose( fp ); fclose( fp );
rename( tmpname, name );
free(tmpname);
return r; return r;
} }