Sequencer: Save file to tmp file before overwriting original.
This commit is contained in:
parent
b3ffef17b5
commit
1a07dda5d9
|
@ -370,11 +370,24 @@ sequence::load ( const char *name )
|
|||
/** save entire sequence to file */
|
||||
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 );
|
||||
|
||||
|
@ -418,6 +431,11 @@ sequence::save ( const char *name ) const
|
|||
}
|
||||
}
|
||||
|
||||
rename(tmp,name);
|
||||
|
||||
free(tmp);
|
||||
}
|
||||
|
||||
|
||||
/*************/
|
||||
/* Accessors */
|
||||
|
|
Loading…
Reference in New Issue