diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2024-10-08 22:44:21 +0200 |
---|---|---|
committer | Christian Soffke <christian.soffke@gmail.com> | 2024-10-26 11:28:22 -0400 |
commit | 04a796fd15f582e38c0216f45a22c572b365457a (patch) | |
tree | 39d284cd2ed9715f7b361190cbc12304d99bd3ac /apps | |
parent | 7592d2ca5eab2e684f45b7a7163f1594f3c36c96 (diff) | |
download | rockbox-04a796fd15f582e38c0216f45a22c572b365457a.tar.gz rockbox-04a796fd15f582e38c0216f45a22c572b365457a.zip |
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
Diffstat (limited to 'apps')
-rw-r--r-- | apps/playlist.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/apps/playlist.c b/apps/playlist.c index 23d3355708..f1edfe7323 100644 --- a/apps/playlist.c +++ b/apps/playlist.c | |||
@@ -367,6 +367,9 @@ static int convert_m3u_name(char* buf, int buf_len, int buf_max, char* temp) | |||
367 | */ | 367 | */ |
368 | static void create_control_unlocked(struct playlist_info* playlist) | 368 | static void create_control_unlocked(struct playlist_info* playlist) |
369 | { | 369 | { |
370 | if (playlist == ¤t_playlist && file_exists(PLAYLIST_CONTROL_FILE)) | ||
371 | rename(PLAYLIST_CONTROL_FILE, PLAYLIST_CONTROL_FILE".old"); | ||
372 | |||
370 | playlist->control_fd = open(playlist->control_filename, | 373 | playlist->control_fd = open(playlist->control_filename, |
371 | O_CREAT|O_RDWR|O_TRUNC, 0666); | 374 | O_CREAT|O_RDWR|O_TRUNC, 0666); |
372 | 375 | ||