Sequencer: Save file to tmp file before overwriting original.
This commit is contained in:
parent
b3ffef17b5
commit
1a07dda5d9
|
@ -371,10 +371,23 @@ sequence::load ( const char *name )
|
|||
void
|
||||
sequence::save ( const char *name ) const
|
||||
{
|
||||
|
||||
char *tmp = NULL;
|
||||
|
||||
{
|
||||
const char *filename = basename(name);
|
||||
char *dir = (char*)malloc( (strlen(name) - strlen(filename)) + 1 );
|
||||
strncpy( dir, name, strlen(name) - strlen(filename) );
|
||||
|
||||
asprintf( &tmp, "%s#%s", dir, filename );
|
||||
free(dir);
|
||||
}
|
||||
|
||||
{
|
||||
smf f;
|
||||
|
||||
/* open for writing */
|
||||
f.open( name, smf::WRITE );
|
||||
f.open( tmp, smf::WRITE );
|
||||
|
||||
f.write_header( 2 );
|
||||
|
||||
|
@ -416,6 +429,11 @@ sequence::save ( const char *name ) const
|
|||
|
||||
p->dump( &f );
|
||||
}
|
||||
}
|
||||
|
||||
rename(tmp,name);
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue