diff options
author | Max Kellermann <max@duempel.org> | 2013-01-03 10:16:05 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-01-03 10:16:05 +0100 |
commit | 90fe4c5124e3fd335f05804d3cc47ba996e62b14 (patch) | |
tree | ef7fb6b3cb2edbe4898431db611f04fb281129fc /src/StateFile.cxx | |
parent | 2452447c814048ed72e95a459c76b4be65962b5c (diff) | |
download | mpd-90fe4c5124e3fd335f05804d3cc47ba996e62b14.tar.gz mpd-90fe4c5124e3fd335f05804d3cc47ba996e62b14.tar.xz mpd-90fe4c5124e3fd335f05804d3cc47ba996e62b14.zip |
TextFile: convert to a class
Diffstat (limited to '')
-rw-r--r-- | src/StateFile.cxx | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/StateFile.cxx b/src/StateFile.cxx index 5af60ddba..cd344eb0e 100644 --- a/src/StateFile.cxx +++ b/src/StateFile.cxx @@ -78,39 +78,31 @@ state_file_write(struct player_control *pc) static void state_file_read(struct player_control *pc) { - FILE *fp; bool success; assert(state_file_path != NULL); g_debug("Loading state file %s", state_file_path); - fp = fopen(state_file_path, "r"); - if (G_UNLIKELY(!fp)) { + TextFile file(state_file_path); + if (file.HasFailed()) { g_warning("failed to open %s: %s", state_file_path, g_strerror(errno)); return; } - GString *buffer = g_string_sized_new(1024); const char *line; - while ((line = read_text_line(fp, buffer)) != NULL) { + while ((line = file.ReadLine()) != NULL) { success = read_sw_volume_state(line) || audio_output_state_read(line) || - playlist_state_restore(line, fp, buffer, - &g_playlist, pc); + playlist_state_restore(line, file, &g_playlist, pc); if (!success) g_warning("Unrecognized line in state file: %s", line); } - fclose(fp); - prev_volume_version = sw_volume_state_get_hash(); prev_output_version = audio_output_state_get_version(); prev_playlist_version = playlist_state_get_hash(&g_playlist, pc); - - - g_string_free(buffer, true); } /** |