TextFile: convert to a class

This commit is contained in:
Max Kellermann
2013-01-03 10:16:05 +01:00
parent 2452447c81
commit 90fe4c5124
17 changed files with 97 additions and 98 deletions

View File

@@ -236,16 +236,14 @@ LoadPlaylistFile(const char *utf8path, GError **error_r)
if (path_fs == NULL)
return contents;
FILE *file = fopen(path_fs, "r");
g_free(path_fs);
if (file == NULL) {
TextFile file(path_fs);
if (file.HasFailed()) {
playlist_errno(error_r);
return contents;
}
GString *buffer = g_string_sized_new(1024);
char *s;
while ((s = read_text_line(file, buffer)) != NULL) {
while ((s = file.ReadLine()) != NULL) {
if (*s == 0 || *s == PLAYLIST_COMMENT)
continue;
@@ -265,7 +263,6 @@ LoadPlaylistFile(const char *utf8path, GError **error_r)
break;
}
fclose(file);
return contents;
}