forked from len0rd/rockbox
playlist: create_control_unlocked: back up current playlist
When creating a new control file for the current playlist, the existing file will now be renamed to serve as a backup, until the next time the control file is replaced again, allowing you to restore the previous state of the playlist, in case you accidentally cleared it. This also means that an entirely new file is created each time, instead of truncating the existing one. Change-Id: I2fd96eb8c3940b85df807fd7646dc0359a036351
This commit is contained in:
parent
7592d2ca5e
commit
04a796fd15
1 changed files with 3 additions and 0 deletions
|
@ -367,6 +367,9 @@ static int convert_m3u_name(char* buf, int buf_len, int buf_max, char* temp)
|
||||||
*/
|
*/
|
||||||
static void create_control_unlocked(struct playlist_info* playlist)
|
static void create_control_unlocked(struct playlist_info* playlist)
|
||||||
{
|
{
|
||||||
|
if (playlist == ¤t_playlist && file_exists(PLAYLIST_CONTROL_FILE))
|
||||||
|
rename(PLAYLIST_CONTROL_FILE, PLAYLIST_CONTROL_FILE".old");
|
||||||
|
|
||||||
playlist->control_fd = open(playlist->control_filename,
|
playlist->control_fd = open(playlist->control_filename,
|
||||||
O_CREAT|O_RDWR|O_TRUNC, 0666);
|
O_CREAT|O_RDWR|O_TRUNC, 0666);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue